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