Trait Run

Source
pub trait Run: Sized {
    // Required methods
    fn run<T>(&self, closure: impl FnOnce(&Self) -> T) -> T;
    fn run_mut<T>(&mut self, closure: impl FnOnce(&mut Self) -> T) -> T;
    fn try_run<T, E>(
        &self,
        closure: impl FnOnce(&Self) -> Result<T, E>,
    ) -> Result<T, E>;
    fn try_run_mut<T, E>(
        &mut self,
        closure: impl FnOnce(&mut Self) -> Result<T, E>,
    ) -> Result<T, E>;
}

Required Methods§

Source

fn run<T>(&self, closure: impl FnOnce(&Self) -> T) -> T

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

Source

fn run_mut<T>(&mut self, closure: impl FnOnce(&mut Self) -> T) -> T

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

Source

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

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

Source

fn try_run_mut<T, E>( &mut self, closure: impl FnOnce(&mut Self) -> Result<T, E>, ) -> Result<T, 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> Run for A