We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b217457 commit 8e12798Copy full SHA for 8e12798
src/vec/from_stream.rs
@@ -1,4 +1,5 @@
1
use std::pin::Pin;
2
+use std::borrow::Cow;
3
4
use crate::stream::{Extend, FromStream, IntoStream};
5
@@ -21,3 +22,21 @@ impl<T> FromStream<T> for Vec<T> {
21
22
})
23
}
24
25
+
26
+impl<'b, T: Clone> FromStream<T> for Cow<'b, [T]> {
27
+ #[inline]
28
+ fn from_stream<'a, S: IntoStream<Item = T>>(
29
+ stream: S,
30
+ ) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
31
+ where
32
+ <S as IntoStream>::IntoStream: 'a,
33
+ {
34
+ let stream = stream.into_stream();
35
36
+ Box::pin(async move {
37
+ pin_utils::pin_mut!(stream);
38
39
+ Cow::Owned(FromStream::from_stream(stream).await)
40
+ })
41
+ }
42
+}
0 commit comments