MapTo

Trait MapTo 

Source
pub trait MapTo<F, X>
where F: FnOnce(Self::Elem) -> X,
{ type Cont<T>: ?Sized; type Elem; // Required method fn apply(&self, f: F) -> Self::Cont<X>; }
Expand description

The MapTo trait is similar to MapInto, but it operates on references to the container rather than consuming it. This allows for mapping functions over the elements of a container while retaining ownership of the original container.

Required Associated Types§

Required Methods§

Source

fn apply(&self, f: F) -> Self::Cont<X>

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.

Implementations on Foreign Types§

Source§

impl<'a, U, V, F> MapTo<F, V> for &'a Vec<U>
where F: FnMut(&U) -> V,

Source§

type Cont<_T> = Vec<_T>

Source§

type Elem = &'a U

Source§

fn apply(&self, f: F) -> <&'a Vec<U> as MapTo<F, V>>::Cont<V>

Source§

impl<'a, U, V, F> MapTo<F, V> for Option<&'a U>
where F: for<'b> FnOnce(&'b U) -> V,

Source§

type Cont<T> = Option<T>

Source§

type Elem = &'a U

Source§

fn apply(&self, f: F) -> <Option<&'a U> as MapTo<F, V>>::Cont<V>

Implementors§