File tree Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ //! The Rust standard collections
2+ //!
3+ //! This library provides efficient implementations of the most common general purpose programming
4+ //! data structures.
5+
6+ mod vec_deque;
7+
8+ pub use vec_deque:: * ;
Original file line number Diff line number Diff line change 1+ use std:: pin:: Pin ;
2+ use std:: collections:: VecDeque ;
3+
4+ use crate :: prelude:: * ;
5+ use crate :: stream:: { Extend , IntoStream } ;
6+
7+ impl < T > Extend < T > for VecDeque < T > {
8+ fn stream_extend < ' a , S : IntoStream < Item = T > + ' a > (
9+ & ' a mut self ,
10+ stream : S ,
11+ ) -> Pin < Box < dyn Future < Output = ( ) > + ' a > > {
12+ let stream = stream. into_stream ( ) ;
13+ //TODO: Add this back in when size_hint is added to Stream/StreamExt
14+ //let (lower_bound, _) = stream.size_hint();
15+ //self.reserve(lower_bound);
16+ Box :: pin ( stream. for_each ( move |item| self . push_back ( item) ) )
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ use std:: pin:: Pin ;
2+ use std:: collections:: VecDeque ;
3+
4+ use crate :: stream:: { Extend , FromStream , IntoStream } ;
5+
6+ impl < T > FromStream < T > for VecDeque < T > {
7+ #[ inline]
8+ fn from_stream < ' a , S : IntoStream < Item = T > > (
9+ stream : S ,
10+ ) -> Pin < Box < dyn core:: future:: Future < Output = Self > + ' a > >
11+ where
12+ <S as IntoStream >:: IntoStream : ' a ,
13+ {
14+ let stream = stream. into_stream ( ) ;
15+
16+ Box :: pin ( async move {
17+ pin_utils:: pin_mut!( stream) ;
18+
19+ let mut out = VecDeque :: new ( ) ;
20+ out. stream_extend ( stream) . await ;
21+ out
22+ } )
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ //! The Rust double-ended queue, implemented with a growable ring buffer.
2+
3+ mod extend;
4+ mod from_stream;
5+
6+ #[ doc( inline) ]
7+ pub use std:: collections:: VecDeque ;
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ cfg_if! {
7070 mod result;
7171 mod option;
7272 mod string;
73+ mod collections;
7374 }
7475}
7576
You can’t perform that action at this time.
0 commit comments