[][src]Trait higher_order_functions::Map

pub trait Map {
    type TFrom;
    type TOut;
    fn map<TTo, F: FnMut(Self::TFrom) -> TTo>(self, f: F) -> Self::TOut;
}

Types containing 'inner' values which can be mapped over.

Examples

Multiplying an array by 2:

use higher_order_functions::Map;

let arr = [1, 4, 6, -3, 6].map(|x| x * 2);

assert_eq!(arr, [2, 8, 12, -6, 12]);

Converting an i32 array to an f64 array:

use higher_order_functions::Map;

let arr = [1, 4, 6, -3, 6].map(f64::from);

assert_eq!(arr, [1.0, 4.0, 6.0, -3.0, 6.0]);

Associated Types

type TFrom

The type of values being mapped over.

type TOut

The generic type of the result after mapping.

Loading content...

Required methods

fn map<TTo, F: FnMut(Self::TFrom) -> TTo>(self, f: F) -> Self::TOut

Apply a function to the inner values of this type.

Loading content...

Implementations on Foreign Types

impl<TFrom, const N: usize> Map for [TFrom; N][src]

Apply a function to all elements of the array.

type TFrom = TFrom

type TOut = [TTo; N]

impl<TFrom> Map for Vec<TFrom>[src]

Apply a function to all elements of the Vec.

type TFrom = TFrom

type TOut = Vec<TTo>

impl<TKey, TFrom> Map for BTreeMap<TKey, TFrom> where
    TKey: Ord
[src]

Apply a function to all values of the BTreeMap.

type TFrom = TFrom

type TOut = BTreeMap<TKey, TTo>

impl<TKey, TFrom> Map for HashMap<TKey, TFrom> where
    TKey: Hash + Eq
[src]

Apply a function to all values of the HashMap.

type TFrom = TFrom

type TOut = HashMap<TKey, TTo>

impl<TFrom> Map for LinkedList<TFrom>[src]

Apply a function to all values of the LinkedList.

type TFrom = TFrom

type TOut = LinkedList<TTo>

impl<TFrom> Map for VecDeque<TFrom>[src]

Apply a function to all values of the VecDeque.

type TFrom = TFrom

type TOut = VecDeque<TTo>

Loading content...

Implementors

Loading content...