2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-04-26 10:16:49 +00:00
async-std/src/vec/from_stream.rs
Sunjay Varma a05b564486 rustfmt
2019-09-30 20:14:16 -04:00

23 lines
544 B
Rust

use std::pin::Pin;
use crate::stream::{Extend, FromStream, IntoStream};
impl<T> FromStream<T> for Vec<T> {
#[inline]
fn from_stream<'a, S: IntoStream<Item = T>>(
stream: S,
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
where
<S as IntoStream>::IntoStream: 'a,
{
let stream = stream.into_stream();
Box::pin(async move {
pin_utils::pin_mut!(stream);
let mut out = vec![];
out.stream_extend(stream).await;
out
})
}
}