Ok<T, E> class
Ok
is a type that represents success and contains a T
type success
value.
- Inheritance
- Available Extensions
- Annotations
-
- @sealed
Constructors
- Ok(T _value)
-
const
Properties
Methods
-
and<
U> (Result< U, E> res) → Result<U, E> -
Returns
res
if the result is Ok, otherwise returns the Err value ofthis
.inherited -
andThen<
U> (Result< U, E> op(T value)) → Result<U, E> -
Calls
op
if the result is Ok, otherwise returns the Err value ofthis
.inherited -
err(
) → E? -
Converts from
Result<T, E>
toE?
.inherited -
errOpt(
) → Option< E> -
Converts from
Result<T, E>
toOption<E>
.inherited -
expect(
String msg) → T -
Returns the contained Ok value, consuming the
this
value.inherited -
expectErr(
String msg) → E -
Returns the contained Err value, consuming the
this
value.inherited -
iter(
) → Iterable< T> -
Returns an iterable over the possibly contained value.
inherited
-
map<
U> (U op(T value)) → Result< U, E> -
Maps a
Result<T, E>
toResult<U, E>
by applying a function to a contained Ok value, leaving an Err value untouched.inherited -
mapErr<
F> (F op(E err)) → Result< T, F> -
Maps a
Result<T, E>
toResult<T, F>
by applying a function to a contained Err value, leaving an Ok value untouched.inherited -
mapOr<
U> (U defaultValue, U f(T value)) → U -
Returns the provided default (if Err), or
applies a function to the contained value (if Ok),
inherited
-
mapOrElse<
U> (U defaultF(E err), U f(T value)) → U -
Maps a
Result<T, E>
toU
by applying fallback functiondefaultF
to a contained Err value, or functionf
to a contained Ok value.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
ok(
) → T? -
Converts from
Result<T, E>
toT?
.inherited -
okOpt(
) → Option< T> -
Converts from
Result<T, E>
toOption<T>
.inherited -
or<
F> (Result< T, F> res) → Result<T, F> -
Returns
res
if the result is Err, otherwise returns the Ok value ofthis
.inherited -
orElse<
F> (Result< T, F> op(E err)) → Result<T, F> -
Calls
op
if the result is Err, otherwise returns the Ok value ofthis
.inherited -
toString(
) → String -
A string representation of this object.
override
-
unwrap(
) → T -
Returns the contained Ok value, consuming the
this
value.inherited -
unwrapErr(
) → E -
Returns the contained Err value, consuming the
this
value.inherited -
unwrapOr(
T defaultValue) → T -
Returns the contained Ok value or a provided default.
inherited
-
unwrapOrElse(
T op(E err)) → T -
Returns the contained Ok value or computes it from a closure.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override