summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/needless_collect.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/needless_collect.txt')
-rw-r--r--src/tools/clippy/src/docs/needless_collect.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/needless_collect.txt b/src/tools/clippy/src/docs/needless_collect.txt
new file mode 100644
index 000000000..275c39afc
--- /dev/null
+++ b/src/tools/clippy/src/docs/needless_collect.txt
@@ -0,0 +1,14 @@
+### What it does
+Checks for functions collecting an iterator when collect
+is not needed.
+
+### Why is this bad?
+`collect` causes the allocation of a new data structure,
+when this allocation may not be needed.
+
+### Example
+```
+let len = iterator.clone().collect::<Vec<_>>().len();
+// should be
+let len = iterator.count();
+``` \ No newline at end of file