Trait higher_order_functions::Map
source · [−]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
Required Methods
Implementations on Foreign Types
sourceimpl<TKey, TFrom> Map for BTreeMap<TKey, TFrom> where
TKey: Ord,
impl<TKey, TFrom> Map for BTreeMap<TKey, TFrom> where
TKey: Ord,
Apply a function to all values of the BTreeMap.
sourceimpl<TKey, TFrom> Map for HashMap<TKey, TFrom> where
TKey: Hash + Eq,
impl<TKey, TFrom> Map for HashMap<TKey, TFrom> where
TKey: Hash + Eq,
Apply a function to all values of the HashMap.
sourceimpl<TFrom> Map for LinkedList<TFrom>
impl<TFrom> Map for LinkedList<TFrom>
Apply a function to all values of the LinkedList.