pub trait UnionZip<K, M> {
// Required method
fn union_zip<'a>(&'a self, other: &'a M) -> UnionZipped<'a, K, M>;
}
Expand description
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>
Implementations on Foreign Types§
source§impl<K, V> UnionZip<K, HashMap<K, V>> for HashMap<K, V>
impl<K, V> UnionZip<K, HashMap<K, V>> for HashMap<K, V>
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());