Signature
Trait functions
then_some
ReturnsSome(t) if the bool is true, None otherwise.
pub trait BoolTrait>
Some(t) if the bool is true, None otherwise.
fn then_some, T, +Drop>(self: bool, t: T) -> Option
assert!(false.then_some(0) == None);
assert!(true.then_some(0) == Some(0));
Was this page helpful?