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> {
124124 Some ( self . cmp ( other) )
125125 }
126126
127+ #[ inline]
127128 fn lt ( & self , other : & Self ) -> bool {
128- !( self >= other)
129+ !self . ge ( other)
129130 }
130131
132+ #[ inline]
131133 fn le ( & self , other : & Self ) -> bool {
132- other >= self
134+ other. ge ( self )
133135 }
134136
137+ #[ inline]
135138 fn gt ( & self , other : & Self ) -> bool {
136- !( other >= self )
139+ !other. ge ( self )
137140 }
138141
142+ #[ inline]
139143 fn ge ( & self , other : & Self ) -> bool {
140144 // We consider all NaNs equal, and NaN is the largest possible
141145 // value. Thus if self is NaN we always return true. Otherwise
@@ -147,7 +151,9 @@ impl<T: FloatCore> PartialOrd for OrderedFloat<T> {
147151}
148152
149153impl < T : FloatCore > Ord for OrderedFloat < T > {
154+ #[ inline]
150155 fn cmp ( & self , other : & Self ) -> Ordering {
156+ #[ allow( clippy:: comparison_chain) ]
151157 if self < other {
152158 Ordering :: Less
153159 } else if self > other {
Original file line number Diff line number Diff line change @@ -26,13 +26,14 @@ fn test_total_order() {
2626 let numberline = [
2727 ( -f32:: INFINITY , 0 ) ,
2828 ( -1.0 , 1 ) ,
29- ( -0.0 , 2 ) , ( 0.0 , 2 ) ,
29+ ( -0.0 , 2 ) ,
30+ ( 0.0 , 2 ) ,
3031 ( 1.0 , 3 ) ,
3132 ( f32:: INFINITY , 4 ) ,
3233 ( f32:: NAN , 5 ) ,
3334 ( -f32:: NAN , 5 ) ,
3435 ] ;
35-
36+
3637 for & ( fi, i) in & numberline {
3738 for & ( fj, j) in & numberline {
3839 assert_eq ! ( OrderedFloat ( fi) < OrderedFloat ( fj) , i < j) ;
You can’t perform that action at this time.
0 commit comments