summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/explicit_iter_loop.txt
blob: cabe72e91d04f6395df2a64f5180c9ec0ebe15e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
### What it does
Checks for loops on `x.iter()` where `&x` will do, and
suggests the latter.

### Why is this bad?
Readability.

### Known problems
False negatives. We currently only warn on some known
types.

### Example
```
// with `y` a `Vec` or slice:
for x in y.iter() {
    // ..
}
```

Use instead:
```
for x in &y {
    // ..
}
```