]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/collapsible_if.txt
Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
[rust.git] / src / tools / clippy / src / docs / collapsible_if.txt
1 ### What it does
2 Checks for nested `if` statements which can be collapsed
3 by `&&`-combining their conditions.
4
5 ### Why is this bad?
6 Each `if`-statement adds one level of nesting, which
7 makes code look more complex than it really is.
8
9 ### Example
10 ```
11 if x {
12     if y {
13         // …
14     }
15 }
16 ```
17
18 Use instead:
19 ```
20 if x && y {
21     // …
22 }
23 ```