]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/unused_peekable.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / unused_peekable.txt
1 ### What it does
2 Checks for the creation of a `peekable` iterator that is never `.peek()`ed
3
4 ### Why is this bad?
5 Creating a peekable iterator without using any of its methods is likely a mistake,
6 or just a leftover after a refactor.
7
8 ### Example
9 ```
10 let collection = vec![1, 2, 3];
11 let iter = collection.iter().peekable();
12
13 for item in iter {
14     // ...
15 }
16 ```
17
18 Use instead:
19 ```
20 let collection = vec![1, 2, 3];
21 let iter = collection.iter();
22
23 for item in iter {
24     // ...
25 }
26 ```