Signature
Trait functions
expect
Returns the containedOk
value, consuming the self
value.
Panics
Panics if the value is anErr
, with the provided felt252
panic message.
Examples
Signature
unwrap
Returns the containedOk
value, consuming the self
value.
Panics
Panics if the value is anErr
, with a standard Result::unwrap failed
panic message.
Examples
Signature
unwrap_or
Returns the containedOk
value or a provided default.
Signature
Examples
unwrap_or_default
Returns the containedOk
value or Default::::default()
.
Signature
Examples
unwrap_or_else
Returns the containedOk
value or computes it from a closure.
Signature
Examples
and
Returnsother
if the result is Ok
, otherwise returns the Err
value of self
.
Signature
Examples
and_then
Callsop
if the result is Ok
, otherwise returns the Err
value of self
.
This function can be used for control flow based on Result
values.
Signature
Examples
or
Returnsother
if the result is Err
, otherwise returns the Ok
value of self
.
Signature
Examples
or_else
Callsop
if the result is Err
, otherwise returns the Ok
value of self
.
This function can be used for control flow based on result values.
Signature
Examples
expect_err
Returns the containedErr
value, consuming the self
value.
Panics
Panics if the value is anOk
, with the provided felt252
panic message.
Examples
Signature
unwrap_err
Returns the containedErr
value, consuming the self
value.
Panics
Panics if the value is anOk
, with a standard Result::unwrap_err failed.
panic message.
Examples
Signature
is_ok
Returnstrue
if the Result
is Ok
.
Signature
Examples
is_err
Returnstrue
if the Result
is Err
.
Signature
Examples
into_is_ok
Returnstrue
if the Result
is Ok
, and consumes the value.
Signature
Examples
into_is_err
Returnstrue
if the Result
is Err
, and consumes the value.
Signature
Examples
ok
Converts fromResult
to Option
.
Converts self
into an Option
, consuming self
,
and discarding the error, if any.
Signature
Examples
err
Converts fromResult
to Option
.
Converts self
into an Option
, consuming self
,
and discarding the success value, if any.
Signature
Examples
map
Maps aResult
to Result
by applying a function to a
contained Ok
value, leaving an Err
value untouched.
This function can be used to compose the results of two functions.
Signature
Examples
Print the square of the number contained in theResult
, otherwise print the error.
map_or
Returns the provided default (ifErr
), or
applies a function to the contained value (if Ok
).
Signature
Examples
map_or_else
Maps aResult
to U
by applying fallback function default
to
a contained Err
value, or function f
to a contained Ok
value.
This function can be used to unpack a successful result
while handling an error.
Signature
Examples
map_err
Maps aResult
to Result
by applying a function to a
contained Err
value, leaving an Ok
value untouched.
This function can be used to pass through a successful result while handling
an error.