Trait With

Source
pub trait With: Sized {
    // Provided methods
    fn wrap_with<U, F: FnOnce(Self) -> U>(self, f: F) -> U { ... }
    fn with<F: FnOnce(&mut Self)>(self, f: F) -> Self { ... }
    fn try_with<E, F>(self, f: F) -> Result<Self, E>
       where F: FnOnce(&mut Self) -> Result<(), E> { ... }
    fn with_if<F>(self, condition: bool, f: F) -> Self
       where F: FnOnce(&mut Self) { ... }
}
Expand description

Generic trait to enable chainable API

Provided Methods§

Source

fn wrap_with<U, F: FnOnce(Self) -> U>(self, f: F) -> U

Calls the given closure and return the result.

Used to chainify wrapper constructors.

Source

fn with<F: FnOnce(&mut Self)>(self, f: F) -> Self

Calls the given closure on self.

Source

fn try_with<E, F>(self, f: F) -> Result<Self, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Calls the given closure on self.

Source

fn with_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure if condition == true.

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: Sized> With for T