summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/iter_next_loop.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/src/docs/iter_next_loop.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/iter_next_loop.txt b/src/tools/clippy/src/docs/iter_next_loop.txt
new file mode 100644
index 000000000..b33eb39d6
--- /dev/null
+++ b/src/tools/clippy/src/docs/iter_next_loop.txt
@@ -0,0 +1,17 @@
+### What it does
+Checks for loops on `x.next()`.
+
+### Why is this bad?
+`next()` returns either `Some(value)` if there was a
+value, or `None` otherwise. The insidious thing is that `Option<_>`
+implements `IntoIterator`, so that possibly one value will be iterated,
+leading to some hard to find bugs. No one will want to write such code
+[except to win an Underhanded Rust
+Contest](https://www.reddit.com/r/rust/comments/3hb0wm/underhanded_rust_contest/cu5yuhr).
+
+### Example
+```
+for x in y.next() {
+ ..
+}
+``` \ No newline at end of file