diff --git a/src/vec/from_stream.rs b/src/vec/from_stream.rs index c813d499..f4ca9a99 100644 --- a/src/vec/from_stream.rs +++ b/src/vec/from_stream.rs @@ -1,5 +1,7 @@ use std::pin::Pin; use std::borrow::Cow; +use std::sync::Arc; +use std::rc::Rc; use crate::stream::{Extend, FromStream, IntoStream}; @@ -58,3 +60,39 @@ impl FromStream for Box<[T]> { }) } } + +impl FromStream for Rc<[T]> { + #[inline] + fn from_stream<'a, S: IntoStream>( + stream: S, + ) -> Pin + 'a>> + where + ::IntoStream: 'a, + { + let stream = stream.into_stream(); + + Box::pin(async move { + pin_utils::pin_mut!(stream); + + Vec::from_stream(stream).await.into() + }) + } +} + +impl FromStream for Arc<[T]> { + #[inline] + fn from_stream<'a, S: IntoStream>( + stream: S, + ) -> Pin + 'a>> + where + ::IntoStream: 'a, + { + let stream = stream.into_stream(); + + Box::pin(async move { + pin_utils::pin_mut!(stream); + + Vec::from_stream(stream).await.into() + }) + } +}