cosmic::prelude

Trait Apply

Source
pub trait Apply<Res> {
    // Provided methods
    fn apply<F>(self, f: F) -> Res
       where F: FnOnce(Self) -> Res,
             Self: Sized { ... }
    fn apply_ref<F>(&self, f: F) -> Res
       where F: FnOnce(&Self) -> Res { ... }
    fn apply_mut<F>(&mut self, f: F) -> Res
       where F: FnOnce(&mut Self) -> Res { ... }
}
Expand description

Represents a type which can have functions applied to it (implemented by default for all types).

Provided Methods§

Source

fn apply<F>(self, f: F) -> Res
where F: FnOnce(Self) -> Res, Self: Sized,

Apply a function which takes the parameter by value.

Source

fn apply_ref<F>(&self, f: F) -> Res
where F: FnOnce(&Self) -> Res,

Apply a function which takes the parameter by reference.

Source

fn apply_mut<F>(&mut self, f: F) -> Res
where F: FnOnce(&mut Self) -> Res,

Apply a function which takes the parameter by mutable reference.

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, Res> Apply<Res> for T
where T: ?Sized,