async_std/collections/binary_heap/
from_stream.rs1use std::collections::BinaryHeap;
2use std::pin::Pin;
3
4use crate::prelude::*;
5use crate::stream::{self, FromStream, IntoStream};
6
7impl<T: Ord> FromStream<T> for BinaryHeap<T> {
8 #[inline]
9 fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
10 stream: S,
11 ) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
12 let stream = stream.into_stream();
13
14 Box::pin(async move {
15 let mut out = BinaryHeap::new();
16 stream::extend(&mut out, stream).await;
17 out
18 })
19 }
20}