[][src]Trait qwutils::imp::Boolinator

pub trait Boolinator {
    pub fn as_option(self) -> Option<()>;
pub fn as_some<T>(self, some: T) -> Option<T>;
pub fn as_some_from<T, F>(self, some: F) -> Option<T>
    where
        F: FnOnce() -> T
;
pub fn and_option<T>(self, opt: Option<T>) -> Option<T>;
pub fn and_option_from<T, F>(self, opt: F) -> Option<T>
    where
        F: FnOnce() -> Option<T>
;
pub fn as_result<T, E>(self, ok: T, err: E) -> Result<T, E>;
pub fn as_result_from<T, E, F, G>(self, ok: F, err: G) -> Result<T, E>
    where
        F: FnOnce() -> T,
        G: FnOnce() -> E
;
pub fn ok_or<E>(self, err: E) -> Result<(), E>;
pub fn ok_or_else<E, G>(self, err: G) -> Result<(), E>
    where
        G: FnOnce() -> E
;
pub fn expect(self, msg: &str); }

This trait defines a number of combinator-style methods for use with bool values.

In general, true/false map to Some(_)/None and Ok(_)/Err(_) respectively.

Required methods

pub fn as_option(self) -> Option<()>[src]

If this value is true, returns Some(()); None otherwise.

pub fn as_some<T>(self, some: T) -> Option<T>[src]

If this value is true, returns Some(some); None otherwise.

pub fn as_some_from<T, F>(self, some: F) -> Option<T> where
    F: FnOnce() -> T, 
[src]

If this value is true, returns Some(some()); None otherwise.

pub fn and_option<T>(self, opt: Option<T>) -> Option<T>[src]

If this value is true, returns opt; None otherwise.

pub fn and_option_from<T, F>(self, opt: F) -> Option<T> where
    F: FnOnce() -> Option<T>, 
[src]

If this value is true, returns opt(); None otherwise.

pub fn as_result<T, E>(self, ok: T, err: E) -> Result<T, E>[src]

If this value is true, returns Ok(ok); Err(err) otherwise.

pub fn as_result_from<T, E, F, G>(self, ok: F, err: G) -> Result<T, E> where
    F: FnOnce() -> T,
    G: FnOnce() -> E, 
[src]

If this value is true, returns Ok(ok()); Err(err()) otherwise.

pub fn ok_or<E>(self, err: E) -> Result<(), E>[src]

If this value is true, returns Ok(()); Err(err) otherwise.

pub fn ok_or_else<E, G>(self, err: G) -> Result<(), E> where
    G: FnOnce() -> E, 
[src]

If this value is true, returns Ok(()); Err(err()) otherwise.

pub fn expect(self, msg: &str)[src]

If this value is true, panics with msg; does nothing otherwise.

Loading content...

Implementations on Foreign Types

impl Boolinator for bool[src]

Loading content...

Implementors

Loading content...