pub trait Map {
    type TFrom;
    type TOut<TTo>;

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

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]);

Required Associated Types

The type of values being mapped over.

The generic type of the result after mapping.

Required Methods

Apply a function to the inner values of this type.

Implementations on Foreign Types

Apply a function to all elements of the array.

Apply a function to all elements of the Vec.

Apply a function to all values of the BTreeMap.

Apply a function to all values of the HashMap.

Apply a function to all values of the LinkedList.

Apply a function to all values of the VecDeque.

Implementors