-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
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.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.