@@ -27,7 +27,10 @@ pin_project! {
27
27
28
28
impl < L : Stream , R : Stream > Merge < L , R > {
29
29
pub ( crate ) fn new ( left : L , right : R ) -> Self {
30
- Self { left : left. fuse ( ) , right : right. fuse ( ) }
30
+ Self {
31
+ left : left. fuse ( ) ,
32
+ right : right. fuse ( ) ,
33
+ }
31
34
}
32
35
}
33
36
@@ -40,14 +43,19 @@ where
40
43
41
44
fn poll_next ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Option < Self :: Item > > {
42
45
let this = self . project ( ) ;
43
- match this. left . poll_next ( cx) {
46
+ let ( first, second) = if ( utils:: random ( 1 ) == 1 ) {
47
+ ( this. left , this. right )
48
+ } else {
49
+ ( this. right , this. left )
50
+ } ;
51
+ match first. poll_next ( cx) {
44
52
Poll :: Ready ( Some ( item) ) => Poll :: Ready ( Some ( item) ) ,
45
- Poll :: Ready ( None ) => this . right . poll_next ( cx) ,
46
- Poll :: Pending => match this . right . poll_next ( cx) {
53
+ Poll :: Ready ( None ) => second . poll_next ( cx) ,
54
+ Poll :: Pending => match second . poll_next ( cx) {
47
55
Poll :: Ready ( Some ( item) ) => Poll :: Ready ( Some ( item) ) ,
48
56
Poll :: Ready ( None ) => Poll :: Pending ,
49
57
Poll :: Pending => Poll :: Pending ,
50
- }
58
+ } ,
51
59
}
52
60
}
53
61
}
0 commit comments