File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ impl<Fut: Unpin> Unpin for SelectAll<Fut> {}
2121/// completion the item resolved will be returned, along with the index of the
2222/// future that was ready and the list of all the remaining futures.
2323///
24+ /// There are no guarantees provided on the order of the list with the remaining
25+ /// futures. They might be swapped around, reversed, or completely random.
26+ ///
2427/// This function is only available when the `std` or `alloc` feature of this
2528/// library is activated, and it is activated by default.
2629///
@@ -50,7 +53,7 @@ impl<Fut: Future + Unpin> Future for SelectAll<Fut> {
5053 } ) ;
5154 match item {
5255 Some ( ( idx, res) ) => {
53- self . inner . remove ( idx) ;
56+ let _ = self . inner . swap_remove ( idx) ;
5457 let rest = mem:: replace ( & mut self . inner , Vec :: new ( ) ) ;
5558 Poll :: Ready ( ( res, idx, rest) )
5659 }
Original file line number Diff line number Diff line change 11use futures:: executor:: block_on;
22use futures:: future:: { ready, select_all} ;
3+ use std:: collections:: HashSet ;
34
45#[ test]
56fn smoke ( ) {
@@ -9,17 +10,20 @@ fn smoke() {
910 ready( 3 ) ,
1011 ] ;
1112
13+ let mut c = vec ! [ 1 , 2 , 3 ] . into_iter ( ) . collect :: < HashSet < _ > > ( ) ;
14+
1215 let ( i, idx, v) = block_on ( select_all ( v) ) ;
13- assert_eq ! ( i , 1 ) ;
16+ assert ! ( c . remove ( & i ) ) ;
1417 assert_eq ! ( idx, 0 ) ;
1518
1619 let ( i, idx, v) = block_on ( select_all ( v) ) ;
17- assert_eq ! ( i , 2 ) ;
20+ assert ! ( c . remove ( & i ) ) ;
1821 assert_eq ! ( idx, 0 ) ;
1922
2023 let ( i, idx, v) = block_on ( select_all ( v) ) ;
21- assert_eq ! ( i , 3 ) ;
24+ assert ! ( c . remove ( & i ) ) ;
2225 assert_eq ! ( idx, 0 ) ;
2326
27+ assert ! ( c. is_empty( ) ) ;
2428 assert ! ( v. is_empty( ) ) ;
2529}
You can’t perform that action at this time.
0 commit comments