-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
Detects match guards that can be collapsed into the pattern.
Categories (optional)
- Kind: complexity
What is the advantage of the recommended code over the original code
It is simpler.
Drawbacks
None.
Example
match x {
Some(x) if matches!(x, Some(1)) => .., // if matches!
Some(x) if x == Some(2) => .., // if ==
x => matches!(x, Some(x) if x == 3), // guard inside matches!
}
Could be written as:
match x {
Some(Some(1)) => ..,
Some(Some(2)) => ..,
x => matches!(x, Some(3)),
}
This lint can share some logic with equatable_if_let
. @HKalbasi maybe you'd like to take this?
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints