resultCtx<T extends Object, E extends Object> function
Result<T, E>
resultCtx<T extends Object, E extends Object>(
- T fn(
- ResultCtx<
T, E>
- ResultCtx<
- E mapErr(
- E
Implementation
Result<T, E> resultCtx<T extends Object, E extends Object>(
T Function(ResultCtx<T, E>) fn, {
E Function(E)? mapErr,
}) {
try {
final ctx = ResultCtx<T, E>();
final ok = fn(ctx);
return Ok(ok);
} on E catch (e) {
final err = mapErr == null ? e : mapErr(e);
return Err(err);
}
}