async_std/collections/hash_map/
from_stream.rs1use std::collections::HashMap;
2use std::hash::{BuildHasher, Hash};
3use std::pin::Pin;
4
5use crate::prelude::*;
6use crate::stream::{self, FromStream, IntoStream};
7
8impl<K, V, H> FromStream<(K, V)> for HashMap<K, V, H>
9where
10 K: Eq + Hash + Send,
11 H: BuildHasher + Default + Send,
12 V: Send,
13{
14 #[inline]
15 fn from_stream<'a, S: IntoStream<Item = (K, V)> + 'a>(
16 stream: S,
17 ) -> Pin<Box<dyn Future<Output = Self> + 'a + Send>>
18 where
19 <S as IntoStream>::IntoStream: Send,
20 {
21 let stream = stream.into_stream();
22
23 Box::pin(async move {
24 let mut out = HashMap::with_hasher(Default::default());
25 stream::extend(&mut out, stream).await;
26 out
27 })
28 }
29}