]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/needless_collect.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / needless_collect.txt
1 ### What it does
2 Checks for functions collecting an iterator when collect
3 is not needed.
4
5 ### Why is this bad?
6 `collect` causes the allocation of a new data structure,
7 when this allocation may not be needed.
8
9 ### Example
10 ```
11 let len = iterator.clone().collect::<Vec<_>>().len();
12 // should be
13 let len = iterator.count();
14 ```