map<U> method

Result<U, E> map<U>(
  1. U fn(
    1. T value
    )
)

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

Implementation

Result<U, E> map<U>(U Function(T value) fn) {
  if (this is Ok<T, E>) {
    return Ok(fn((this as Ok<T, E>).value));
  }
  return this as Result<U, E>;
}