Skip to content

Commit 3cf01a8

Browse files
orlpmbrubeck
authored andcommitted
Silence clippy, fmt, and add missing inline directives
1 parent 2753a02 commit 3cf01a8

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
@@ -119,18 +119,22 @@ impl<T: Float> PartialOrd for OrderedFloat<T> {
119119
Some(self.cmp(other))
120120
}
121121

122+
#[inline]
122123
fn lt(&self, other: &Self) -> bool {
123-
!(self >= other)
124+
!self.ge(other)
124125
}
125126

127+
#[inline]
126128
fn le(&self, other: &Self) -> bool {
127-
other >= self
129+
other.ge(self)
128130
}
129131

132+
#[inline]
130133
fn gt(&self, other: &Self) -> bool {
131-
!(other >= self)
134+
!other.ge(self)
132135
}
133136

137+
#[inline]
134138
fn ge(&self, other: &Self) -> bool {
135139
// We consider all NaNs equal, and NaN is the largest possible
136140
// value. Thus if self is NaN we always return true. Otherwise
@@ -142,6 +146,8 @@ impl<T: Float> PartialOrd for OrderedFloat<T> {
142146
}
143147

144148
impl<T: Float> Ord for OrderedFloat<T> {
149+
#[inline]
150+
#[allow(clippy::comparison_chain)]
145151
fn cmp(&self, other: &Self) -> Ordering {
146152
if self < other {
147153
Ordering::Less

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)