transf<R extends Object> method
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<R> transf<R extends Object>([
@noFuturesAllowed R Function(T e)? noFuturesAllowed,
]) {
try {
final a = unwrap();
final b = noFuturesAllowed?.call(a) ?? a as R;
return Ok(b);
} catch (e) {
assert(false, e);
return Err('Cannot transform $T to $R.');
}
}