2 Checks for deriving `Ord` but implementing `PartialOrd`
3 explicitly or vice versa.
6 The implementation of these traits must agree (for
7 example for use with `sort`) so it’s probably a bad idea to use a
8 default-generated `Ord` implementation with an explicitly defined
9 `PartialOrd`. In particular, the following must hold for any type
13 k1.cmp(&k2) == k1.partial_cmp(&k2).unwrap()
18 #[derive(Ord, PartialEq, Eq)]
21 impl PartialOrd for Foo {
27 #[derive(PartialEq, Eq)]
30 impl PartialOrd for Foo {
31 fn partial_cmp(&self, other: &Foo) -> Option<Ordering> {
40 or, if you don't need a custom ordering:
42 #[derive(Ord, PartialOrd, PartialEq, Eq)]