File tree 2 files changed +11
-4
lines changed
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> {}
21
21
/// completion the item resolved will be returned, along with the index of the
22
22
/// future that was ready and the list of all the remaining futures.
23
23
///
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
+ ///
24
27
/// This function is only available when the `std` or `alloc` feature of this
25
28
/// library is activated, and it is activated by default.
26
29
///
@@ -50,7 +53,7 @@ impl<Fut: Future + Unpin> Future for SelectAll<Fut> {
50
53
} ) ;
51
54
match item {
52
55
Some ( ( idx, res) ) => {
53
- self . inner . remove ( idx) ;
56
+ let _ = self . inner . swap_remove ( idx) ;
54
57
let rest = mem:: replace ( & mut self . inner , Vec :: new ( ) ) ;
55
58
Poll :: Ready ( ( res, idx, rest) )
56
59
}
Original file line number Diff line number Diff line change 1
1
use futures:: executor:: block_on;
2
2
use futures:: future:: { ready, select_all} ;
3
+ use std:: collections:: HashSet ;
3
4
4
5
#[ test]
5
6
fn smoke ( ) {
@@ -9,17 +10,20 @@ fn smoke() {
9
10
ready( 3 ) ,
10
11
] ;
11
12
13
+ let mut c = vec ! [ 1 , 2 , 3 ] . into_iter ( ) . collect :: < HashSet < _ > > ( ) ;
14
+
12
15
let ( i, idx, v) = block_on ( select_all ( v) ) ;
13
- assert_eq ! ( i , 1 ) ;
16
+ assert ! ( c . remove ( & i ) ) ;
14
17
assert_eq ! ( idx, 0 ) ;
15
18
16
19
let ( i, idx, v) = block_on ( select_all ( v) ) ;
17
- assert_eq ! ( i , 2 ) ;
20
+ assert ! ( c . remove ( & i ) ) ;
18
21
assert_eq ! ( idx, 0 ) ;
19
22
20
23
let ( i, idx, v) = block_on ( select_all ( v) ) ;
21
- assert_eq ! ( i , 3 ) ;
24
+ assert ! ( c . remove ( & i ) ) ;
22
25
assert_eq ! ( idx, 0 ) ;
23
26
27
+ assert ! ( c. is_empty( ) ) ;
24
28
assert ! ( v. is_empty( ) ) ;
25
29
}
You can’t perform that action at this time.
0 commit comments