map<R extends Object> method

  1. @override
Result<R> map<R extends Object>(
  1. @noFutures R noFutures(
    1. T value
    )
)
override

Applies noFutures to the contained value and wraps the result in Ok. Any throw from the callback becomes an Err. Widened from Ok<R> to Result<R> so the absorbed error has a place to live.

Implementation

@override
@pragma('vm:prefer-inline')
Result<R> map<R extends Object>(@noFutures R Function(T value) noFutures) {
  try {
    return Ok(noFutures(value));
  } on Err catch (err) {
    return err.transfErr<R>();
  } catch (error, stackTrace) {
    return Err<R>(error, stackTrace: stackTrace);
  }
}