mapErr<F extends BaseException> method

Result<T, F> mapErr<F extends BaseException>(
  1. F f(
    1. E error
    )
)

Maps the error type when present, preserving successes.

Implementation

Result<T, F> mapErr<F extends BaseException>(F Function(E error) f) {
  final self = this;
  if (self is Err<T, E>) return Err<T, F>(f(self.error));
  return Ok<T, F>((self as Ok<T, E>).value);
}