]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/collapsible_else_if.txt
Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup
[rust.git] / src / tools / clippy / src / docs / collapsible_else_if.txt
1 ### What it does
2 Checks for collapsible `else { if ... }` expressions
3 that can be collapsed to `else if ...`.
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
12 if x {
13     …
14 } else {
15     if y {
16         …
17     }
18 }
19 ```
20
21 Should be written:
22
23 ```
24 if x {
25     …
26 } else if y {
27     …
28 }
29 ```