]> git.lizzy.rs Git - rust.git/blob - src/docs/iter_next_loop.txt
Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnr
[rust.git] / src / docs / iter_next_loop.txt
1 ### What it does
2 Checks for loops on `x.next()`.
3
4 ### Why is this bad?
5 `next()` returns either `Some(value)` if there was a
6 value, or `None` otherwise. The insidious thing is that `Option<_>`
7 implements `IntoIterator`, so that possibly one value will be iterated,
8 leading to some hard to find bugs. No one will want to write such code
9 [except to win an Underhanded Rust
10 Contest](https://www.reddit.com/r/rust/comments/3hb0wm/underhanded_rust_contest/cu5yuhr).
11
12 ### Example
13 ```
14 for x in y.next() {
15     ..
16 }
17 ```