transf<R extends Object> method
Result<Option<R> >
transf<R extends Object>([
- @noFuturesAllowed R noFuturesAllowed(
- T e
override
Transforms the Monad's generic type from T
to R
.
Uses the transformer function noFuturesAllowed
if provided, otherwise
attempts a direct cast.
Implementation
@override
Result<Option<R>> transf<R extends Object>([
@noFuturesAllowed R Function(T e)? noFuturesAllowed,
]) {
try {
UNSAFE:
final value0 = unwrap();
final value1 = noFuturesAllowed?.call(value0) ?? value0 as R;
return Ok(Option.from(value1));
} catch (e) {
assert(false, e);
return Err('Cannot transform $T to $R');
}
}