impl FromStream for Box<[T]>

pull/271/head
Sunjay Varma 5 years ago
parent 8e12798038
commit 63c6b1cb63

@ -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…
Cancel
Save