MapInto

Trait MapInto 

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

MapInto defines an interface for containers capable of applying a given function onto each of their elements and consuming the container in the process, producing a new container containing the captured results of each invocation. The trait’s design allows implementors to specify the exact function signature and output type, utilizing associated type parameters to define the container and its current element type.

Required Associated Types§

Source

type Cont<_T>: ?Sized

Source

type Elem

the current type of element associated with the contained

Required Methods§

Source

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

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, F, X, Y> MapInto<F, Y> for &'a Option<X>
where F: FnOnce(&X) -> Y,

Source§

type Cont<U> = Option<U>

Source§

type Elem = &'a X

Source§

fn apply(self, f: F) -> <&'a Option<X> as MapInto<F, Y>>::Cont<Y>

Source§

impl<F, X, Y> MapInto<F, Y> for Vec<X>
where F: FnMut(X) -> Y, Vec<Y>: FromIterator<Y>,

Source§

type Cont<_U> = Vec<_U>

Source§

type Elem = X

Source§

fn apply(self, f: F) -> <Vec<X> as MapInto<F, Y>>::Cont<Y>

Source§

impl<U, V, F> MapInto<F, V> for Option<U>
where F: FnOnce(U) -> V,

Source§

type Cont<T> = Option<T>

Source§

type Elem = U

Source§

fn apply(self, f: F) -> <Option<U> as MapInto<F, V>>::Cont<V>

Implementors§