summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/iter_next_loop.txt
blob: b33eb39d6e1d37529ed4969f94d4cf2c107d5042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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() {
    ..
}
```