]> git.lizzy.rs Git - rust.git/blob - src/docs/needless_bitwise_bool.txt
Auto merge of #9425 - kraktus:patch-1, r=xFrednet
[rust.git] / src / docs / needless_bitwise_bool.txt
1 ### What it does
2 Checks for uses of bitwise and/or operators between booleans, where performance may be improved by using
3 a lazy and.
4
5 ### Why is this bad?
6 The bitwise operators do not support short-circuiting, so it may hinder code performance.
7 Additionally, boolean logic "masked" as bitwise logic is not caught by lints like `unnecessary_fold`
8
9 ### Known problems
10 This lint evaluates only when the right side is determined to have no side effects. At this time, that
11 determination is quite conservative.
12
13 ### Example
14 ```
15 let (x,y) = (true, false);
16 if x & !y {} // where both x and y are booleans
17 ```
18 Use instead:
19 ```
20 let (x,y) = (true, false);
21 if x && !y {}
22 ```