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
```
This commit is contained in:
Taiki Endo 2023-10-08 14:38:07 +09:00
parent 30296f9582
commit 4d1362c16b
1 changed files with 1 additions and 3 deletions

View File

@ -30,9 +30,7 @@ impl Eq for ByDuration {}
impl PartialOrd for ByDuration {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.duration()
.partial_cmp(&other.duration())
.map(|ord| ord.reverse())
Some(self.cmp(other))
}
}