diff options
Diffstat (limited to 'src/stream_map.rs')
-rw-r--r-- | src/stream_map.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/stream_map.rs b/src/stream_map.rs index 9dc529a..80a521e 100644 --- a/src/stream_map.rs +++ b/src/stream_map.rs @@ -568,6 +568,23 @@ where } } +impl<K, V> std::iter::FromIterator<(K, V)> for StreamMap<K, V> +where + K: Hash + Eq, +{ + fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self { + let iterator = iter.into_iter(); + let (lower_bound, _) = iterator.size_hint(); + let mut stream_map = Self::with_capacity(lower_bound); + + for (key, value) in iterator { + stream_map.insert(key, value); + } + + stream_map + } +} + mod rand { use std::cell::Cell; |