ResultQuery<T, E> extension

Asking a Result what it holds, and taking the value out.

final passed = const Ok<int, String>(90).isOkAnd((score) => score >= 50);
final score = const Ok<int, String>(90).ok(); // Some(90)
on

Methods

err() → Option<E>

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

The error as Some, or None for an Ok.
expect(String message) → T

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

Returns the successful value, or throws message for an Err.
expectErr(String message) → E

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

Returns the error, or throws message for an Ok.
isErrAnd(bool predicate(E error)) → bool

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

Whether the result failed and its error satisfies predicate.
isOkAnd(bool predicate(T value)) → bool

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

Whether the result succeeded and its value satisfies predicate.
ok() → Option<T>

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

The successful value as Some, or None for an Err.
unwrap() → T

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

Returns the successful value, or throws for an Err.
unwrapErr() → E

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

Returns the error, or throws for an Ok.