Trait itermap::IterMap[][src]

pub trait IterMap<I, K, V>: Sized {
    fn map_keys<Fk, J>(self, f: Fk) -> MapKeys<I, Fk>
Notable traits for MapKeys<I, F>
impl<I, F, K, J, V> Iterator for MapKeys<I, F> where
    I: Iterator<Item = (K, V)>,
    F: FnMut(K) -> J, 
type Item = (J, V);

    where
        Fk: FnMut(K) -> J
;
fn map_values<Fv, U>(self, f: Fv) -> MapValues<I, Fv>
Notable traits for MapValues<I, F>
impl<I, F, K, V, W> Iterator for MapValues<I, F> where
    I: Iterator<Item = (K, V)>,
    F: FnMut(V) -> W, 
type Item = (K, W);

    where
        Fv: FnMut(V) -> U
; }
Expand description

Adds additional methods for Iterators over maps (e.g., HashMap, BTreeMap, etc.) and other two-element tuples (like (K, V)).

Required methods

Maps map keys (or the first element of a two-element tuple like (K, V)), leaving other elements intact and untouched.

Example
use itermap::IterMap;

let mut hash: HashMap<&str, &str> = HashMap::new();
hash.insert("a", "A");
hash.insert("b", "B");

let hash: HashMap<String, &str> = hash
    .into_iter()
    .map_keys(String::from)
    .collect();

Maps map values (or the second element of a two-element tuple like (K, V)), leaving other elements intact and untouched.

Example
use itermap::IterMap;

let mut hash: HashMap<&str, &str> = HashMap::new();
hash.insert("a", "A");
hash.insert("b", "B");

let hash: HashMap<&str, String> = hash
    .into_iter()
    .map_values(String::from)
    .collect();

Implementors