-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesS-fixedStatus: Issues that got fixed, waiting to be closed as completedStatus: Issues that got fixed, waiting to be closed as completed
Description
What it does
Catch code that flips a boolean with a match statement, as well as code that applies the identity function over a boolean with a match statement.
Lints for code like this exists:
let a = true;
let b = if a { false } else { true };
let c = if b == true { false } else { true };
let d = if c { true } else { false };
but there seems to be no lint for code like this:
let a = true;
let b = match a{
true => false,
false => true,
};
I saw someone writing that piece of code, so it could be useful if there was a lint for it.
Categories (optional)
clippy::style
What is the advantage of the recommended code over the original code
- The recommended is code is shorter and more readable.
Drawbacks
None.
Example 0
let a = true;
let b = match a{
true => false,
false => true,
};
Could be written as:
let a = true;
let b = !a;
Example 1
let a = true;
let b = match a{
true => true,
false => false,
};
Could be written as:
let a = true;
let b = a;
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesS-fixedStatus: Issues that got fixed, waiting to be closed as completedStatus: Issues that got fixed, waiting to be closed as completed