Trait Apply

Source
pub trait Apply: Sized {
    // Required methods
    fn apply(&self, closure: impl FnOnce(&Self)) -> &Self;
    fn apply_mut(&mut self, closure: impl FnOnce(&mut Self)) -> &mut Self;
    fn try_apply<E>(
        &self,
        closure: impl FnOnce(&Self) -> Result<(), E>,
    ) -> Result<&Self, E>;
    fn try_apply_mut<E>(
        &mut self,
        closure: impl FnOnce(&mut Self) -> Result<(), E>,
    ) -> Result<&mut Self, E>;
}

Required Methods§

Source

fn apply(&self, closure: impl FnOnce(&Self)) -> &Self

Calls the specified closure with Self as an argument and returns Self.

Source

fn apply_mut(&mut self, closure: impl FnOnce(&mut Self)) -> &mut Self

Calls the specified closure with mutable Self as an argument and returns Self.

Source

fn try_apply<E>( &self, closure: impl FnOnce(&Self) -> Result<(), E>, ) -> Result<&Self, E>

Calls the specified closure with Self as an argument and returns a Result.

Source

fn try_apply_mut<E>( &mut self, closure: impl FnOnce(&mut Self) -> Result<(), E>, ) -> Result<&mut Self, E>

Calls the specified closure with mutable Self as an argument and returns a Result.

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<A: Sized> Apply for A