summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/needless_collect.txt
blob: 275c39afc9df1064a40fe5d2b7eae33bba0a3992 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
### What it does
Checks for functions collecting an iterator when collect
is not needed.

### Why is this bad?
`collect` causes the allocation of a new data structure,
when this allocation may not be needed.

### Example
```
let len = iterator.clone().collect::<Vec<_>>().len();
// should be
let len = iterator.count();
```