Skip to content

suggest replacing if comparison chain with cmp match #4531

Closed
@oli-cosmian

Description

@oli-cosmian

If one writes

if x < y {
     ...
} else if x > y {
     ...
} else {
     ...
}

one should instead be writing

match x.cmp(&y) {
     Ordering::Less => ...,
     Ordering::Greater => ...,
     Ordering::Equal => ...,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsL-styleLint: Belongs in the style lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions