]> git.lizzy.rs Git - rust.git/blob - src/docs/blocks_in_if_conditions.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / blocks_in_if_conditions.txt
1 ### What it does
2 Checks for `if` conditions that use blocks containing an
3 expression, statements or conditions that use closures with blocks.
4
5 ### Why is this bad?
6 Style, using blocks in the condition makes it hard to read.
7
8 ### Examples
9 ```
10 if { true } { /* ... */ }
11
12 if { let x = somefunc(); x } { /* ... */ }
13 ```
14
15 Use instead:
16 ```
17 if true { /* ... */ }
18
19 let res = { let x = somefunc(); x };
20 if res { /* ... */ }
21 ```