ResultTransform<T, E> extension

Transforming and choosing between Result values.

final label = const Ok<int, String>(3).mapOr('failed', (n) => '$n items');
final chosen = const Err<int, String>('cache').or(const Ok<int, String>(1));
on

Methods

and<R>(Result<R, E> other) → Result<R, E>

Available on Result<T, E>, provided by the ResultTransform extension

Returns other when this result succeeded, or this error otherwise.
inspect(void action(T value)) → Result<T, E>

Available on Result<T, E>, provided by the ResultTransform extension

Calls action with a successful value, and returns this result unchanged.
inspectErr(void action(E error)) → Result<T, E>

Available on Result<T, E>, provided by the ResultTransform extension

Calls action with the error, and returns this result unchanged.
mapOr<R>(R fallback, R mapper(T value)) → R

Available on Result<T, E>, provided by the ResultTransform extension

Maps a successful value, or returns fallback for an Err.
mapOrElse<R>(R fallback(E error), R mapper(T value)) → R

Available on Result<T, E>, provided by the ResultTransform extension

Maps a successful value, or computes a fallback from the error.
or<F>(Result<T, F> other) → Result<T, F>

Available on Result<T, E>, provided by the ResultTransform extension

Returns this result when it succeeded, or other otherwise.