Transformers<T, E> extension

Transforming contained values

on

Methods

map<U>(U okMap(T value)) Result<U, E>
Maps a Result<T, E> to Result<U, E> by applying a function to a contained ok (success) value, and leaving an err (failure) value untouched.
mapErr<F>(F errMap(E error)) Result<T, F>
Maps a Result<T, E> to Result<T, F> by applying a function to a contained err (failure) value, leaving an ok (success) value untouched.
mapOr<U>({required U fallback, required U okMap(T value)}) → U
Returns the provided fallback (if err (failure)), or applies a function to the contained value (if ok (success)).
mapOrElse<U>({required U errMap(E error), required U okMap(T value)}) → U
Maps a Result<T, E> to U by applying fallback function fallback to a contained err (failure) value, or function op to a contained ok (success) value.