Trait BoolExt

Source
pub trait BoolExt: Sized {
    // Required methods
    fn into_option(self) -> Option<()>;
    fn into_result(self) -> Result<(), ()>;

    // Provided methods
    fn and<T>(self, option: Option<T>) -> Option<T> { ... }
    fn and_then<T, F>(self, f: F) -> Option<T>
       where F: FnOnce() -> Option<T> { ... }
    fn then<T, F>(self, f: F) -> Option<T>
       where F: FnOnce() -> T { ... }
    fn then_ext<T, F>(self, f: F) -> Option<T>
       where F: FnOnce() -> T { ... }
    fn then_some<T>(self, value: T) -> Option<T> { ... }
    fn then_some_ext<T>(self, value: T) -> Option<T> { ... }
    fn ok_or<E>(self, error: E) -> Result<(), E> { ... }
    fn ok_or_else<E, F>(self, f: F) -> Result<(), E>
       where F: FnOnce() -> E { ... }
}

Required Methods§

Provided Methods§

Source

fn and<T>(self, option: Option<T>) -> Option<T>

Source

fn and_then<T, F>(self, f: F) -> Option<T>
where F: FnOnce() -> Option<T>,

Source

fn then<T, F>(self, f: F) -> Option<T>
where F: FnOnce() -> T,

Source

fn then_ext<T, F>(self, f: F) -> Option<T>
where F: FnOnce() -> T,

Source

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

Source

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

Source

fn ok_or<E>(self, error: E) -> Result<(), E>

Source

fn ok_or_else<E, F>(self, f: F) -> Result<(), E>
where F: FnOnce() -> E,

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.

Implementations on Foreign Types§

Source§

impl BoolExt for bool

Implementors§