Skip to main content

Apply

Trait Apply 

Source
pub trait Apply<T> {
    type Cont<_T>;

    // Required method
    fn apply<U, F>(&self, rhs: F) -> Self::Cont<U>
       where F: FnOnce(&T) -> U;
}
Expand description

Apply is a trait that allows for mapping over a reference to a type T by applying a function F to it, producing a new type U. The result is wrapped in a container type defined by the implementor of the trait.

Required Associated Types§

Source

type Cont<_T>

The associated type Cont is a higher-kinded type that represents the container that will hold the result of the mapping operation.

Required Methods§

Source

fn apply<U, F>(&self, rhs: F) -> Self::Cont<U>
where F: FnOnce(&T) -> U,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Apply<T> for Option<T>

Source§

type Cont<U> = Option<U>

Source§

fn apply<U, F>(&self, rhs: F) -> Self::Cont<U>
where F: FnOnce(&T) -> U,

Implementors§