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 @@ -119,18 +119,22 @@ impl<T: Float> PartialOrd for OrderedFloat<T> {
119
119
Some ( self . cmp ( other) )
120
120
}
121
121
122
+ #[ inline]
122
123
fn lt ( & self , other : & Self ) -> bool {
123
- !( self >= other)
124
+ !self . ge ( other)
124
125
}
125
126
127
+ #[ inline]
126
128
fn le ( & self , other : & Self ) -> bool {
127
- other >= self
129
+ other. ge ( self )
128
130
}
129
131
132
+ #[ inline]
130
133
fn gt ( & self , other : & Self ) -> bool {
131
- !( other >= self )
134
+ !other. ge ( self )
132
135
}
133
136
137
+ #[ inline]
134
138
fn ge ( & self , other : & Self ) -> bool {
135
139
// We consider all NaNs equal, and NaN is the largest possible
136
140
// value. Thus if self is NaN we always return true. Otherwise
@@ -142,6 +146,8 @@ impl<T: Float> PartialOrd for OrderedFloat<T> {
142
146
}
143
147
144
148
impl < T : Float > Ord for OrderedFloat < T > {
149
+ #[ inline]
150
+ #[ allow( clippy:: comparison_chain) ]
145
151
fn cmp ( & self , other : & Self ) -> Ordering {
146
152
if self < other {
147
153
Ordering :: Less
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