Loading RustViz Engine...
Write monadic combinatorial operations on a custom Result<T, E> data structure.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
pub enum MyResult<T, E> { Ok(T), Err(E) }
impl<T, E> MyResult<T, E> {
pub fn fold<U, F1: FnOnce(T) -> U, F2: FnOnce(E) -> U>(self, ok_fn: F1, err_fn: F2) -> U {
match self {
MyResult::Ok(val) => ok_fn(val),
MyResult::Err(err) => err_fn(err),
}
}
}