]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/src/docs/unnecessary_fold.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / unnecessary_fold.txt
CommitLineData
f2b60f7d
FG
1### What it does
2Checks for using `fold` when a more succinct alternative exists.
3Specifically, this checks for `fold`s which could be replaced by `any`, `all`,
4`sum` or `product`.
5
6### Why is this bad?
7Readability.
8
9### Example
10```
11(0..3).fold(false, |acc, x| acc || x > 2);
12```
13
14Use instead:
15```
16(0..3).any(|x| x > 2);
17```