Skip to content

Multiple if-let arms can be replaced with match #7481

Open
@In-line

Description

@In-line

Example

if let TestEnum::B(_) = *self {
    return true;
}
if let TestEnum::C(_) = *self {
    return true;
}
false

Could be written as:

match self {
    TestEnum::B(_) | TestEnum::C(_) => true,
    _ => false,
}

Playground link

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions