@@ -2,8 +2,8 @@ use std::cmp::Ordering;
2
2
use std:: pin:: Pin ;
3
3
4
4
use super :: fuse:: Fuse ;
5
- use crate :: prelude:: * ;
6
5
use crate :: future:: Future ;
6
+ use crate :: prelude:: * ;
7
7
use crate :: stream:: Stream ;
8
8
use crate :: task:: { Context , Poll } ;
9
9
@@ -15,7 +15,7 @@ pub struct CmpFuture<L: Stream, R: Stream> {
15
15
l : Fuse < L > ,
16
16
r : Fuse < R > ,
17
17
l_cache : Option < L :: Item > ,
18
- r_cache : Option < R :: Item > ,
18
+ r_cache : Option < R :: Item > ,
19
19
}
20
20
21
21
impl < L : Stream , R : Stream > CmpFuture < L , R > {
@@ -28,35 +28,35 @@ impl<L: Stream, R: Stream> CmpFuture<L, R> {
28
28
CmpFuture {
29
29
l : l. fuse ( ) ,
30
30
r : r. fuse ( ) ,
31
- l_cache : None ,
32
- r_cache : None ,
31
+ l_cache : None ,
32
+ r_cache : None ,
33
33
}
34
34
}
35
35
}
36
36
37
- impl < L : Stream , R : Stream > Future for CmpFuture < L , R >
38
- where
37
+ impl < L : Stream , R : Stream > Future for CmpFuture < L , R >
38
+ where
39
39
L : Stream + Sized ,
40
40
R : Stream < Item = L :: Item > + Sized ,
41
- L :: Item : Ord ,
41
+ L :: Item : Ord ,
42
42
{
43
43
type Output = Ordering ;
44
44
45
- fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
45
+ fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
46
46
loop {
47
47
// Stream that completes earliest can be considered Less, etc
48
48
let l_complete = self . l . done && self . as_mut ( ) . l_cache . is_none ( ) ;
49
49
let r_complete = self . r . done && self . as_mut ( ) . r_cache . is_none ( ) ;
50
50
51
51
if l_complete && r_complete {
52
- return Poll :: Ready ( Ordering :: Equal )
52
+ return Poll :: Ready ( Ordering :: Equal ) ;
53
53
} else if l_complete {
54
- return Poll :: Ready ( Ordering :: Less )
54
+ return Poll :: Ready ( Ordering :: Less ) ;
55
55
} else if r_complete {
56
- return Poll :: Ready ( Ordering :: Greater )
56
+ return Poll :: Ready ( Ordering :: Greater ) ;
57
57
}
58
58
59
- // Get next value if possible and necesary
59
+ // Get next value if possible and necesary
60
60
if !self . l . done && self . as_mut ( ) . l_cache . is_none ( ) {
61
61
let l_next = futures_core:: ready!( self . as_mut( ) . l( ) . poll_next( cx) ) ;
62
62
if let Some ( item) = l_next {
@@ -74,18 +74,18 @@ where
74
74
// Compare if both values are available.
75
75
if self . as_mut ( ) . l_cache . is_some ( ) && self . as_mut ( ) . r_cache . is_some ( ) {
76
76
let l_value = self . as_mut ( ) . l_cache ( ) . take ( ) . unwrap ( ) ;
77
- let r_value = self . as_mut ( ) . r_cache ( ) . take ( ) . unwrap ( ) ;
77
+ let r_value = self . as_mut ( ) . r_cache ( ) . take ( ) . unwrap ( ) ;
78
78
let result = l_value. cmp ( & r_value) ;
79
79
80
80
if let Ordering :: Equal = result {
81
- // Reset cache to prepare for next comparison
82
- * self . as_mut ( ) . l_cache ( ) = None ;
81
+ // Reset cache to prepare for next comparison
82
+ * self . as_mut ( ) . l_cache ( ) = None ;
83
83
* self . as_mut ( ) . r_cache ( ) = None ;
84
84
} else {
85
- // Return non equal value
85
+ // Return non equal value
86
86
return Poll :: Ready ( result) ;
87
- }
87
+ }
88
88
}
89
89
}
90
90
}
91
- }
91
+ }
0 commit comments