]> git.lizzy.rs Git - rust.git/blob - src/docs/explicit_iter_loop.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / explicit_iter_loop.txt
1 ### What it does
2 Checks for loops on `x.iter()` where `&x` will do, and
3 suggests the latter.
4
5 ### Why is this bad?
6 Readability.
7
8 ### Known problems
9 False negatives. We currently only warn on some known
10 types.
11
12 ### Example
13 ```
14 // with `y` a `Vec` or slice:
15 for x in y.iter() {
16     // ..
17 }
18 ```
19
20 Use instead:
21 ```
22 for x in &y {
23     // ..
24 }
25 ```