MapInto

Trait MapInto 

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

MapInto describes a consuming interface for containers that enables the mapping of a given function onto each element of the container. While the trait definition constrains the generic function parameters, F to a FnOnce closure, implementors coulds choose to strengthen this constraint to FnMut or Fn as needed.

Required Associated Types§

Source

type Cont<U>: ?Sized

Source

type Elem

the current type of element associated with the contained

Required Methods§

Source

fn map_into(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, 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 map_into(self, f: F) -> Self::Cont<Y>

Source§

impl<F, X, Y> MapInto<F, Y> for Option<X>
where F: FnOnce(X) -> Y,

Source§

type Cont<U> = Option<U>

Source§

type Elem = X

Source§

fn map_into(self, f: F) -> Self::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 map_into(self, f: F) -> Self::Cont<Y>

Implementors§