-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
A-lintArea: New lintsArea: New lintsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
What it does
This lint should prohibit placing bool
returning if
statements as the expression inside another if
statement. Currently, there appears to be no limit to the depth of stacked if
's permitted by both rust fmt
and clippy
Advantage
- Stacked
if
's are hard to read
Drawbacks
- Ternary-style expressions couldn't be used inside an
if
statement, but I personally think that's poor form
Example
if if if a == b {
b == c
} else {
a == c
} {
a == d
} else {
c == d
} {
println!("True!");
} else {
println!("False!");
}
Could be written as:
let expression_1 = if a == b {
b == c
} else {
a == c
};
let expression_2 = if expression_1 {
a == d
} else {
c == d
};
if expression_2 {
println!("True!");
} else {
println!("False!");
}
willhansen, MingweiSamuel, ameknite, Stumblinbear, popematt and 16 moreCrypto-Spartan, mlindner, ebkalderon and OthersRudxain and schneiderfelipe
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy