[][src]Trait math::iter::union_zip::UnionZip

pub trait UnionZip<K, M> {
    fn union_zip<'a>(&'a self, other: &'a M) -> UnionZipped<'a, K, M>;
}

K is the key type M is the map type that maps keys of type K to values

Required methods

fn union_zip<'a>(&'a self, other: &'a M) -> UnionZipped<'a, K, M>

Loading content...

Implementations on Foreign Types

impl<K, V> UnionZip<K, HashMap<K, V, RandomState>> for HashMap<K, V> where
    K: Hash + Eq + Clone + Ord
[src]

Takes the sorted union of the two sets of keys for future iteration

use math::iter::UnionZip;
use std::collections::HashMap;
let m1: HashMap<i32, i32> = vec![(1, 10), (3, 23), (4, 20)].into_iter().collect();
let m2: HashMap<i32, i32> = vec![(0, 4), (1, 20), (4, 20), (9, 29)]
    .into_iter()
    .collect();

let mut iter = m1.union_zip(&m2).into_iter();
assert_eq!(Some((0, vec![None, Some(&4)])), iter.next());
assert_eq!(Some((1, vec![Some(&10), Some(&20)])), iter.next());
assert_eq!(Some((3, vec![Some(&23), None])), iter.next());
assert_eq!(Some((4, vec![Some(&20), Some(&20)])), iter.next());
assert_eq!(Some((9, vec![None, Some(&29)])), iter.next());
assert_eq!(None, iter.next());
Loading content...

Implementors

Loading content...