mapAsync<U> method

Future<Result<U, E>> mapAsync<U>(
  1. Future<U> f(
    1. T value
    )
)

Maps the success value using an async transformer, preserving errors.

Implementation

Future<Result<U, E>> mapAsync<U>(Future<U> Function(T value) f) async {
  final self = this;
  if (self is Ok<T, E>) return Ok<U, E>(await f(self.value));
  return Err<U, E>((self as Err<T, E>).error);
}