Skip to content

Commit a5390f8

Browse files
orlpmbrubeck
authored andcommitted
Silence clippy, fmt, and add missing inline directives
1 parent 84e9ae2 commit a5390f8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,22 @@ impl<T: Float> PartialOrd for OrderedFloat<T> {
125125
Some(self.cmp(other))
126126
}
127127

128+
#[inline]
128129
fn lt(&self, other: &Self) -> bool {
129-
!(self >= other)
130+
!self.ge(other)
130131
}
131132

133+
#[inline]
132134
fn le(&self, other: &Self) -> bool {
133-
other >= self
135+
other.ge(self)
134136
}
135137

138+
#[inline]
136139
fn gt(&self, other: &Self) -> bool {
137-
!(other >= self)
140+
!other.ge(self)
138141
}
139142

143+
#[inline]
140144
fn ge(&self, other: &Self) -> bool {
141145
// We consider all NaNs equal, and NaN is the largest possible
142146
// value. Thus if self is NaN we always return true. Otherwise
@@ -148,7 +152,9 @@ impl<T: Float> PartialOrd for OrderedFloat<T> {
148152
}
149153

150154
impl<T: Float> Ord for OrderedFloat<T> {
155+
#[inline]
151156
fn cmp(&self, other: &Self) -> Ordering {
157+
#[allow(clippy::comparison_chain)]
152158
if self < other {
153159
Ordering::Less
154160
} else if self > other {

tests/test.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ fn test_total_order() {
2727
let numberline = [
2828
(-f32::INFINITY, 0),
2929
(-1.0, 1),
30-
(-0.0, 2), (0.0, 2),
30+
(-0.0, 2),
31+
(0.0, 2),
3132
(1.0, 3),
3233
(f32::INFINITY, 4),
3334
(f32::NAN, 5),
3435
(-f32::NAN, 5),
3536
];
36-
37+
3738
for &(fi, i) in &numberline {
3839
for &(fj, j) in &numberline {
3940
assert_eq!(OrderedFloat(fi) < OrderedFloat(fj), i < j);

0 commit comments

Comments
 (0)