Trait CallOn

Source
pub trait CallOn<T>: CallInto<T> {
    // Required method
    fn call_on<F>(&self, f: F) -> Self::Output
       where F: FnMut(&T) -> Self::Output;
}
Expand description

The CallOn trait enables an object to be passed onto a unary, or single value, function that is applied to the object.

Required Methods§

Source

fn call_on<F>(&self, f: F) -> Self::Output
where F: FnMut(&T) -> Self::Output,

The call_on method allows an object to be passed onto a function that takes a reference to the object. This is useful for cases where you want to perform an operation on an object without needing to extract it from a container or context.

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> CallOn<T> for T
where T: CallInto<T>,