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