File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ use std:: pin:: Pin ;
2+ use std:: collections:: BTreeSet ;
3+
4+ use crate :: prelude:: * ;
5+ use crate :: stream:: { Extend , IntoStream } ;
6+
7+ impl < T : Ord > Extend < T > for BTreeSet < 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+ Box :: pin ( stream. into_stream ( ) . for_each ( move |item| {
13+ self . insert ( item) ;
14+ } ) )
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ use std:: pin:: Pin ;
2+ use std:: collections:: BTreeSet ;
3+
4+ use crate :: stream:: { Extend , FromStream , IntoStream } ;
5+
6+ impl < T : Ord > FromStream < T > for BTreeSet < 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 = BTreeSet :: 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 B-Tree Set
2+
3+ mod extend;
4+ mod from_stream;
5+
6+ #[ doc( inline) ]
7+ pub use std:: collections:: BTreeSet ;
Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ pub mod vec_deque;
77pub mod hash_map;
88pub mod hash_set;
99pub mod btree_map;
10+ pub mod btree_set;
1011
1112pub use vec_deque:: VecDeque ;
1213pub use hash_map:: HashMap ;
1314pub use hash_set:: HashSet ;
1415pub use btree_map:: BTreeMap ;
16+ pub use btree_set:: BTreeSet ;
You can’t perform that action at this time.
0 commit comments