Re-exported from core::option::Option.
forall T.
exposed enum Option {
Some(T),
None,
}
A value that is either present as Some(T) or absent as None. Its multiplicity follows T, so an option can carry a linear value.
Methods
method unwrap_orsource
fn unwrap_or(self, fallback: T) -> T { ... }
The value, or fallback when there is none. Copy only: a linear fallback would be dropped when there is a value.
method is_somesource
fn is_some(self) -> bool { ... }
Whether there is a value. A linear payload is asked with match &x instead.
method is_nonesource
fn is_none(self) -> bool { ... }
Whether there is no value.
method unwrapsource
fn unwrap(self) -> T { ... }
The value; stops the program (core::process::trap) when there is none. For an absence that is a bug, not an outcome to handle.
method mapsource
forall U, Env where Copy[Env].
fn map(self, f: closure[Env](T) -> U) -> Option[U] { ... }
f of the value, if there is one. Copy[Env]: with no value, f is dropped uncalled.
method and_thensource
forall U, Env where Copy[Env].
fn and_then(self, f: closure[Env](T) -> Option[U]) -> Option[U] { ... }
f of the value, which may itself be absent.
method unwrap_or_elsesource
forall Env where Copy[Env].
fn unwrap_or_else(self, f: closure[Env]() -> T) -> T { ... }
The value, or f() when there is none.
method map_orsource
forall U, Env where Copy[U], Copy[Env].
fn map_or(self, fallback: U, f: closure[Env](T) -> U) -> U { ... }
f of the value, or fallback when there is none. Copy[U]: one of fallback and f's result is dropped.
method ok_orsource
forall E where Copy[E].
fn ok_or(self, error: E) -> Result[T, E] { ... }
Ok of the value, or Err.(error) when there is none. Copy[E]: with a value, error is dropped.