]>
Commit | Line | Data |
---|---|---|
f2b60f7d FG |
1 | ### What it does |
2 | Checks whether a for loop has a single element. | |
3 | ||
4 | ### Why is this bad? | |
5 | There is no reason to have a loop of a | |
6 | single element. | |
7 | ||
8 | ### Example | |
9 | ``` | |
10 | let item1 = 2; | |
11 | for item in &[item1] { | |
12 | println!("{}", item); | |
13 | } | |
14 | ``` | |
15 | ||
16 | Use instead: | |
17 | ``` | |
18 | let item1 = 2; | |
19 | let item = &item1; | |
20 | println!("{}", item); | |
21 | ``` |