Skip to content

Commit 63c6b1c

Browse files
committed
impl FromStream for Box<[T]>
1 parent 8e12798 commit 63c6b1c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/vec/from_stream.rs

+18
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,21 @@ impl<'b, T: Clone> FromStream<T> for Cow<'b, [T]> {
4040
})
4141
}
4242
}
43+
44+
impl<T> FromStream<T> for Box<[T]> {
45+
#[inline]
46+
fn from_stream<'a, S: IntoStream<Item = T>>(
47+
stream: S,
48+
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
49+
where
50+
<S as IntoStream>::IntoStream: 'a,
51+
{
52+
let stream = stream.into_stream();
53+
54+
Box::pin(async move {
55+
pin_utils::pin_mut!(stream);
56+
57+
Vec::from_stream(stream).await.into_boxed_slice()
58+
})
59+
}
60+
}

0 commit comments

Comments
 (0)