summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/single_element_loop.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/src/docs/single_element_loop.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/single_element_loop.txt b/src/tools/clippy/src/docs/single_element_loop.txt
new file mode 100644
index 000000000..6f0c15a85
--- /dev/null
+++ b/src/tools/clippy/src/docs/single_element_loop.txt
@@ -0,0 +1,21 @@
+### What it does
+Checks whether a for loop has a single element.
+
+### Why is this bad?
+There is no reason to have a loop of a
+single element.
+
+### Example
+```
+let item1 = 2;
+for item in &[item1] {
+ println!("{}", item);
+}
+```
+
+Use instead:
+```
+let item1 = 2;
+let item = &item1;
+println!("{}", item);
+``` \ No newline at end of file