Trait stry_common::utils::IntoResult[][src]

pub trait IntoResult where
    Self: Sized
{ fn ok_if<E>(self, predicate: bool, err: E) -> Result<Self, E> { ... }
fn with_ok_if<F, E>(self, predicate: F, err: E) -> Result<Self, E>
    where
        F: FnOnce(&Self) -> bool
, { ... }
fn err_if<E>(self, predicate: bool, err: E) -> Result<Self, E> { ... }
fn with_err_if<F, E>(self, predicate: F, err: E) -> Result<Self, E>
    where
        F: FnOnce(&Self) -> bool
, { ... } }

Wrap Self in a Result based off a predicate.

Provided methods

fn ok_if<E>(self, predicate: bool, err: E) -> Result<Self, E>[src]

Results Ok(self) if the predicate returns true, or Err(err) otherwise.

fn with_ok_if<F, E>(self, predicate: F, err: E) -> Result<Self, E> where
    F: FnOnce(&Self) -> bool
[src]

Results Ok(self) if the predicate returns true, or Err(err) otherwise.

fn err_if<E>(self, predicate: bool, err: E) -> Result<Self, E>[src]

Results Err(err) if the predicate returns true, or Ok(self) otherwise.

fn with_err_if<F, E>(self, predicate: F, err: E) -> Result<Self, E> where
    F: FnOnce(&Self) -> bool
[src]

Results Err(err) if the predicate returns true, or Ok(self) otherwise.

Loading content...

Implementors

impl<T> IntoResult for T[src]

Loading content...