Closed
Description
It seems that the comparison functions are not correctly implemented.
I tried this code:
use std::cmp::Ordering;
assert_eq!([1].iter().cmp([1, 2].iter()), Ordering::Less);
assert_eq!([1, 2].iter().cmp([1].iter()), Ordering::Greater);
I expected to see this happen:
The code above should panic. The reason is: 1 is NOT less than 1 and 1 is NOT greater than 1.
What I'm missing in Ordering are LessOrEqual and GreaterOrEqual. If these 2 objects would exist I could write:
use std::cmp::Ordering;
assert_eq!([1].iter().cmp([1, 2].iter()), Ordering::LessOrEqual);
assert_eq!([1, 2].iter().cmp([1].iter()), Ordering::GreaterOrEqual);
which would correct not panic.
Meta
I've tried this in Rust Playground with stable and nightly.