about summary refs log tree commit diff
path: root/src/docs/single_element_loop.txt
blob: 6f0c15a85f7749176320797287631a87305b0ead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
### What it does
Checks whether a for loop has a single element.

### Why is this bad?
There is no reason to have a loop of a
single element.

### Example
```
let item1 = 2;
for item in &[item1] {
    println!("{}", item);
}
```

Use instead:
```
let item1 = 2;
let item = &item1;
println!("{}", item);
```