Option¶
No import is needed.
Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.
Option¶
Option<T> - a value that is either present (Some) or absent (None).
Some¶
Contains a value of type T.
None¶
No value is present.
is_some¶
True when this is Some.
is_none¶
True when this is None.
unwrap_or¶
The contained value when Some, otherwise fallback.
unwrap¶
The contained value, or panics if None.
expect¶
The contained value, or panics with msg if None.
unwrap_or_else¶
The contained value, or f() when None.
filter¶
Some when the value is present and pred is true, otherwise None.
ok_or¶
Ok when Some, otherwise Err(err).
flatten¶
Collapses Option<Option<U>>.
map¶
Maps the contained value when Some, otherwise None.
and_then¶
Chains into another Option when Some, otherwise None.
or¶
This option when Some, otherwise fallback.