@@ -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 PartialCmpFuture<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 > PartialCmpFuture < L , R > {
@@ -28,36 +28,36 @@ impl<L: Stream, R: Stream> PartialCmpFuture<L, R> {
28
28
PartialCmpFuture {
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 PartialCmpFuture < L , R >
38
- where
37
+ impl < L : Stream , R : Stream > Future for PartialCmpFuture < L , R >
38
+ where
39
39
L : Stream + Sized ,
40
40
R : Stream + Sized ,
41
- L :: Item : PartialOrd < R :: Item >
41
+ L :: Item : PartialOrd < R :: Item > ,
42
42
{
43
43
type Output = Option < 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
- // Short circuit logic
47
+ // Short circuit logic
48
48
// Stream that completes earliest can be considered Less, etc
49
49
let l_complete = self . l . done && self . as_mut ( ) . l_cache . is_none ( ) ;
50
50
let r_complete = self . r . done && self . as_mut ( ) . r_cache . is_none ( ) ;
51
51
52
52
if l_complete && r_complete {
53
- return Poll :: Ready ( Some ( Ordering :: Equal ) )
53
+ return Poll :: Ready ( Some ( Ordering :: Equal ) ) ;
54
54
} else if l_complete {
55
- return Poll :: Ready ( Some ( Ordering :: Less ) )
55
+ return Poll :: Ready ( Some ( Ordering :: Less ) ) ;
56
56
} else if r_complete {
57
- return Poll :: Ready ( Some ( Ordering :: Greater ) )
57
+ return Poll :: Ready ( Some ( Ordering :: Greater ) ) ;
58
58
}
59
59
60
- // Get next value if possible and necesary
60
+ // Get next value if possible and necesary
61
61
if !self . l . done && self . as_mut ( ) . l_cache . is_none ( ) {
62
62
let l_next = futures_core:: ready!( self . as_mut( ) . l( ) . poll_next( cx) ) ;
63
63
if let Some ( item) = l_next {
@@ -75,17 +75,17 @@ where
75
75
// Compare if both values are available.
76
76
if self . as_mut ( ) . l_cache . is_some ( ) && self . as_mut ( ) . r_cache . is_some ( ) {
77
77
let l_value = self . as_mut ( ) . l_cache ( ) . take ( ) . unwrap ( ) ;
78
- let r_value = self . as_mut ( ) . r_cache ( ) . take ( ) . unwrap ( ) ;
78
+ let r_value = self . as_mut ( ) . r_cache ( ) . take ( ) . unwrap ( ) ;
79
79
let result = l_value. partial_cmp ( & r_value) ;
80
80
81
81
if let Some ( Ordering :: Equal ) = result {
82
- // Reset cache to prepare for next comparison
83
- * self . as_mut ( ) . l_cache ( ) = None ;
82
+ // Reset cache to prepare for next comparison
83
+ * self . as_mut ( ) . l_cache ( ) = None ;
84
84
* self . as_mut ( ) . r_cache ( ) = None ;
85
85
} else {
86
- // Return non equal value
86
+ // Return non equal value
87
87
return Poll :: Ready ( result) ;
88
- }
88
+ }
89
89
}
90
90
}
91
91
}
0 commit comments