Skip to content

Commit 71770b3

Browse files
committed
Silence clippy, fmt, and add missing inline directives
1 parent 06884ae commit 71770b3

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
@@ -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

149153
impl<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 {

tests/test.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)