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
-
- Result<
T, E>
- Result<
Methods
-
and<
R> (Result< R, E> other) → Result<R, E> -
Available on Result<
ReturnsT, E> , provided by the ResultTransform extensionotherwhen this result succeeded, or this error otherwise. -
inspect(
void action(T value)) → Result< T, E> -
Available on Result<
CallsT, E> , provided by the ResultTransform extensionactionwith a successful value, and returns this result unchanged. -
inspectErr(
void action(E error)) → Result< T, E> -
Available on Result<
CallsT, E> , provided by the ResultTransform extensionactionwith the error, and returns this result unchanged. -
mapOr<
R> (R fallback, R mapper(T value)) → R -
Available on Result<
Maps a successful value, or returnsT, E> , provided by the ResultTransform extensionfallbackfor an Err. -
mapOrElse<
R> (R fallback(E error), R mapper(T value)) → R -
Available on Result<
Maps a successful value, or computes a fallback from the error.T, E> , provided by the ResultTransform extension -
or<
F> (Result< T, F> other) → Result<T, F> -
Available on Result<
Returns this result when it succeeded, orT, E> , provided by the ResultTransform extensionotherotherwise.