blob: a063c8195ef57f1d893d3662ab0bd90f2005ef4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
### What it does
Checks for iterating a map (`HashMap` or `BTreeMap`) and
ignoring either the keys or values.
### Why is this bad?
Readability. There are `keys` and `values` methods that
can be used to express that we only need the keys or the values.
### Example
```
let map: HashMap<u32, u32> = HashMap::new();
let values = map.iter().map(|(_, value)| value).collect::<Vec<_>>();
```
Use instead:
```
let map: HashMap<u32, u32> = HashMap::new();
let values = map.values().collect::<Vec<_>>();
```
|