summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/unnecessary_fold.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/unnecessary_fold.txt')
-rw-r--r--src/tools/clippy/src/docs/unnecessary_fold.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/unnecessary_fold.txt b/src/tools/clippy/src/docs/unnecessary_fold.txt
new file mode 100644
index 000000000..e1b0e65f5
--- /dev/null
+++ b/src/tools/clippy/src/docs/unnecessary_fold.txt
@@ -0,0 +1,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);
+``` \ No newline at end of file