imply_option

Trait ImplyOption

Source
pub trait ImplyOption<T: Sized>: Sized + PartialEq<bool> {
    // Provided methods
    fn then(self, value: T) -> Option<T> { ... }
    fn then_do(self, value: impl FnOnce() -> T) -> Option<T> { ... }
}
Expand description

Allows construction of an Option<T> based on a bool.

Provided Methods§

Source

fn then(self, value: T) -> Option<T>

If self == true returns Some(value).

Source

fn then_do(self, value: impl FnOnce() -> T) -> Option<T>

If self == true returns Some(value) where value is lazily constructed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Sized + PartialEq<bool>, I: Sized> ImplyOption<I> for T