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,
11 H: BuildHasher + Default,
12{
13 #[inline]
14 fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
15 stream: S,
16 ) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
17 let stream = stream.into_stream();
18
19 Box::pin(async move {
20 let mut out = HashSet::with_hasher(Default::default());
21 stream::extend(&mut out, stream).await;
22 out
23 })
24 }
25}