diff --git a/tokio-stream/src/stream_map.rs b/tokio-stream/src/stream_map.rs index 9dc529ac0b3..80a521ee17a 100644 --- a/tokio-stream/src/stream_map.rs +++ b/tokio-stream/src/stream_map.rs @@ -568,6 +568,23 @@ where } } +impl std::iter::FromIterator<(K, V)> for StreamMap +where + K: Hash + Eq, +{ + fn from_iter>(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;