Signature

pub trait BoolTrait>

Trait functions

then_some

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

Signature

fn then_some, T, +Drop>(self: bool, t: T) -> Option

Examples

assert!(false.then_some(0) == None);
assert!(true.then_some(0) == Some(0));