diff --git a/src/lib.rs b/src/lib.rs index 9521e74f..3b572aa1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1517,6 +1517,16 @@ impl Extend<(K, V)> for OrderMap } } +impl<'a, K, V, S> Extend<(&'a K, &'a V)> for OrderMap + where K: Hash + Eq + Copy, + V: Copy, + S: BuildHasher, +{ + fn extend>(&mut self, iterable: I) { + self.extend(iterable.into_iter().map(|(&key, &value)| (key, value))); + } +} + impl Default for OrderMap where S: BuildHasher + Default, { @@ -1755,4 +1765,12 @@ mod tests { assert_ne!(map_a, map_c); assert_ne!(map_c, map_a); } + + #[test] + fn extend() { + let mut map = OrderMap::new(); + map.extend(vec![(&1, &2), (&3, &4)]); + map.extend(vec![(5, 6)]); + assert_eq!(map.into_iter().collect::>(), vec![(1, 2), (3, 4), (5, 6)]); + } }