File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -125,18 +125,22 @@ impl<T: Float> PartialOrd for OrderedFloat<T> {
125
125
Some ( self . cmp ( other) )
126
126
}
127
127
128
+ #[ inline]
128
129
fn lt ( & self , other : & Self ) -> bool {
129
- !( self >= other)
130
+ !self . ge ( other)
130
131
}
131
132
133
+ #[ inline]
132
134
fn le ( & self , other : & Self ) -> bool {
133
- other >= self
135
+ other. ge ( self )
134
136
}
135
137
138
+ #[ inline]
136
139
fn gt ( & self , other : & Self ) -> bool {
137
- !( other >= self )
140
+ !other. ge ( self )
138
141
}
139
142
143
+ #[ inline]
140
144
fn ge ( & self , other : & Self ) -> bool {
141
145
// We consider all NaNs equal, and NaN is the largest possible
142
146
// value. Thus if self is NaN we always return true. Otherwise
@@ -148,7 +152,9 @@ impl<T: Float> PartialOrd for OrderedFloat<T> {
148
152
}
149
153
150
154
impl < T : Float > Ord for OrderedFloat < T > {
155
+ #[ inline]
151
156
fn cmp ( & self , other : & Self ) -> Ordering {
157
+ #[ allow( clippy:: comparison_chain) ]
152
158
if self < other {
153
159
Ordering :: Less
154
160
} else if self > other {
Original file line number Diff line number Diff line change @@ -27,13 +27,14 @@ fn test_total_order() {
27
27
let numberline = [
28
28
( -f32:: INFINITY , 0 ) ,
29
29
( -1.0 , 1 ) ,
30
- ( -0.0 , 2 ) , ( 0.0 , 2 ) ,
30
+ ( -0.0 , 2 ) ,
31
+ ( 0.0 , 2 ) ,
31
32
( 1.0 , 3 ) ,
32
33
( f32:: INFINITY , 4 ) ,
33
34
( f32:: NAN , 5 ) ,
34
35
( -f32:: NAN , 5 ) ,
35
36
] ;
36
-
37
+
37
38
for & ( fi, i) in & numberline {
38
39
for & ( fj, j) in & numberline {
39
40
assert_eq ! ( OrderedFloat ( fi) < OrderedFloat ( fj) , i < j) ;
You can’t perform that action at this time.
0 commit comments