Module std::option

Optional values

The main type in this module Option. It can be used to represent a value that may or may not be present. An Option type can be some or none.

An Option type is useful for return values that may legitimately have no value. If an operation is expected to produce a value, but can encounter an error, it is more idiomatic to represent it with Result.

Option types can be combined in a method-chaining style using combinators such as map and and_then. They can also be unpacked with using try expressions.


Optional value



Extract the value or short-circuit the calling function.