In the derived partial_cmp the comparisons stops when inner partial_cmp returns
None. The implementation for lt, le, gt, ge are also provided, but they
continue the comparisons instead as if compared values were considered equal.
This behaviour is also inconsistent with the implementation for tuples / slices:
#[derive(PartialEq, PartialOrd)]
struct P(f64, f64);
fn main() {
let a = (f64::NAN, 0.0);
let b = (f64::NAN, 1.0);
// Tuples:
assert_eq!(PartialOrd::partial_cmp(&a, &b), None);
assert!(!(a < b));
// Arrays:
let a = [f64::NAN, 0.0];
let b = [f64::NAN, 1.0];
assert_eq!(PartialOrd::partial_cmp(&a, &b), None);
assert!(!(a < b));
// Derived:
let a = P(f64::NAN, 0.0);
let b = P(f64::NAN, 1.0);
assert_eq!(PartialOrd::partial_cmp(&a, &b), None);
assert!(!(a < b)); // fails
}
In the derived
partial_cmpthe comparisons stops when innerpartial_cmpreturnsNone. The implementation forlt,le,gt,geare also provided, but theycontinue the comparisons instead as if compared values were considered equal.
This behaviour is also inconsistent with the implementation for tuples / slices: