Skip to content

Ordering should include LessEq and GreaterEq #1149

@mdinger

Description

@mdinger

I tried to replace a set of if a < b {} else ... with an Ordering and the result wasn't so nice.

if a <= b {}
else {}

Can be replaced with:

match a.cmp(&b) {
    Ordering::Less => {},
    Ordering::Equal => {},
    _ => {},
}
match a.cmp(&b) {
    Ordering::Less | Ordering::Equal => {},
    _ => {},
}

But this would be nicer:

match a.cmp(&b) {
    Ordering::LessEq => {},
    _ => {},

I'm not sure how important this is though. a <= b reads so much nicer. I'm not sure where Ordering has a really strong usecase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions