mirror of
https://github.com/async-rs/async-std.git
synced 2025-01-16 10:49:55 +00:00
impl FromStream for Box<[T]>
This commit is contained in:
parent
8e12798038
commit
63c6b1cb63
1 changed files with 18 additions and 0 deletions
|
@ -40,3 +40,21 @@ impl<'b, T: Clone> FromStream<T> for Cow<'b, [T]> {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> FromStream<T> for Box<[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);
|
||||
|
||||
Vec::from_stream(stream).await.into_boxed_slice()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue