[][src]Trait intoif::IntoResult

pub trait IntoResult where
    Self: Sized
{ fn ok_if<P, E>(self, predicate: P, error: E) -> Result<Self, E>
    where
        P: FnOnce(&Self) -> bool
, { ... }
fn ok_if_else<P, E, F>(self, predicate: P, error: F) -> Result<Self, E>
    where
        P: FnOnce(&Self) -> bool,
        F: FnOnce() -> E
, { ... }
fn err_if<P, E>(self, predicate: P, error: E) -> Result<Self, E>
    where
        P: FnOnce(&Self) -> bool
, { ... }
fn err_if_else<P, E, F>(self, predicate: P, error: F) -> Result<Self, E>
    where
        P: FnOnce(&Self) -> bool,
        F: FnOnce() -> E
, { ... } }

Allow construction of Result from any type using predicate to choose between Ok and Err.

Provided methods

fn ok_if<P, E>(self, predicate: P, error: E) -> Result<Self, E> where
    P: FnOnce(&Self) -> bool, 

Returns Ok(self) if predicate returns true on self, Err(error) otherwise.

fn ok_if_else<P, E, F>(self, predicate: P, error: F) -> Result<Self, E> where
    P: FnOnce(&Self) -> bool,
    F: FnOnce() -> E, 

Returns Ok(self) if predicate returns true on self, Err(error) otherwise. This is a lazy version of ok_if, error is constructed only when the predicate fails.

fn err_if<P, E>(self, predicate: P, error: E) -> Result<Self, E> where
    P: FnOnce(&Self) -> bool, 

Returns Err(error) if predicate returns true on self, Ok(self) otherwise.

fn err_if_else<P, E, F>(self, predicate: P, error: F) -> Result<Self, E> where
    P: FnOnce(&Self) -> bool,
    F: FnOnce() -> E, 

Returns Err(error) if predicate returns true on self, Ok(self) otherwise. This is a lazy version of err_if, error is constructed only when the predicate succeeds.

Loading content...

Implementors

impl<T> IntoResult for T[src]

Loading content...