IntoResult

Trait IntoResult 

Source
pub trait IntoResult
where Self: Sized,
{ // Provided methods 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 { ... } }
Expand description

Wrap Self in a Result based off a predicate.

Provided Methods§

Source

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

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

Source

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

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

Source

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

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

Source

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

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

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> IntoResult for T