mirror of https://github.com/smol-rs/async-task
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:
parent
30296f9582
commit
4d1362c16b
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue