::std::

Module bool

Implementations

impl bool
pub fn then_some<T>(self, t: T) -> Option<T>

Returns Some(t) if the bool is true, or None otherwise.

Examples

assert false.then_some(67u8) == None;
assert true.then_some(67u8) == Some(67u8);