Skip to content

Commit 4d1362c

Browse files
committed
Fix clippy::non_canonical_partial_ord_impl warning in example
``` warning: non-canonical implementation of `partial_cmp` on an `Ord` type --> examples/with-metadata.rs:31:1 | 31 | / impl PartialOrd for ByDuration { 32 | | fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | | _______________________________________________________________________- 33 | || self.duration() 34 | || .partial_cmp(&other.duration()) 35 | || .map(|ord| ord.reverse()) 36 | || } | ||_____- help: change this to: `{ Some(self.cmp(other)) }` 37 | | } | |__^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#non_canonical_partial_ord_impl = note: `#[warn(clippy::non_canonical_partial_ord_impl)]` on by default ```
1 parent 30296f9 commit 4d1362c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

examples/with-metadata.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ impl Eq for ByDuration {}
3030

3131
impl PartialOrd for ByDuration {
3232
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
33-
self.duration()
34-
.partial_cmp(&other.duration())
35-
.map(|ord| ord.reverse())
33+
Some(self.cmp(other))
3634
}
3735
}
3836

0 commit comments

Comments
 (0)