mapErr<F> method

Result<T, F> mapErr<F>(
  1. F fn(
    1. E error
    )
)

Maps the error inside Err if it exists, keeping Ok unchanged.

Implementation

Result<T, F> mapErr<F>(F Function(E error) fn) {
  if (this is Err<T, E>) {
    return Err(fn((this as Err<T, E>).error));
  }
  return this as Result<T, F>;
}