summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/fn_params_excessive_bools.txt
blob: 2eae0563368c1adb6e91dc7080d1c839e5c07141 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
### What it does
Checks for excessive use of
bools in function definitions.

### Why is this bad?
Calls to such functions
are confusing and error prone, because it's
hard to remember argument order and you have
no type system support to back you up. Using
two-variant enums instead of bools often makes
API easier to use.

### Example
```
fn f(is_round: bool, is_hot: bool) { ... }
```

Use instead:
```
enum Shape {
    Round,
    Spiky,
}

enum Temperature {
    Hot,
    IceCold,
}

fn f(shape: Shape, temperature: Temperature) { ... }
```