summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/unnecessary_fold.txt
blob: e1b0e65f51971971a41a2495cc0493924ddaa664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
### What it does
Checks for using `fold` when a more succinct alternative exists.
Specifically, this checks for `fold`s which could be replaced by `any`, `all`,
`sum` or `product`.

### Why is this bad?
Readability.

### Example
```
(0..3).fold(false, |acc, x| acc || x > 2);
```

Use instead:
```
(0..3).any(|x| x > 2);
```