module std::optionsource
The optional value: a payload (Some) or its absence (None).
Option is a lang item (LANGUAGE_SPEC.md section 6.1a) at the canonical
path std::option::Option: the compiler's cursor-protocol for lowering
matches on the Option returned by an iterator's next. Nothing here is
otherwise special; it is an ordinary generic enum. An option of a
disposable payload is disposable itself (section 5.2).
type Optionsource
exp type Option<T> : Disposable if (T: Disposable) + Format if (T: Format) = enum
Variants
Some: TNone
Functions
fn disposesource
exp fn dispose<T: Disposable>(self option: &var Option<T>)
Disposes the payload, if any.
fn formatsource
exp fn format<T: Format>(self option: &Option<T>, out: &var String)
Writes Some(payload) or None (std::format).
fn is_somesource
exp fn is_some<T>(self option: &Option<T>) -> bool
True when the option carries a payload.
fn is_nonesource
exp fn is_none<T>(self option: &Option<T>) -> bool
True when the option is empty.
fn unwrap_orsource
exp fn unwrap_or<T>(self option: &Option<T>, fallback: T) -> T
The payload when present, otherwise the given fallback. The payload is returned as a copy (deep, when T owns heap); the fallback moves out.