]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/iter_count.txt
Auto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-dead
[rust.git] / src / tools / clippy / src / docs / iter_count.txt
1 ### What it does
2 Checks for the use of `.iter().count()`.
3
4 ### Why is this bad?
5 `.len()` is more efficient and more
6 readable.
7
8 ### Example
9 ```
10 let some_vec = vec![0, 1, 2, 3];
11
12 some_vec.iter().count();
13 &some_vec[..].iter().count();
14 ```
15
16 Use instead:
17 ```
18 let some_vec = vec![0, 1, 2, 3];
19
20 some_vec.len();
21 &some_vec[..].len();
22 ```