RS.CLIPPY.UNUSED_PEEKABLE

Creating a peekable iterator without using any of its methods

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unused_peekable. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for the creation of a peekable iterator that is never .peek()ed

Why is this bad?

Creating a peekable iterator without using any of its methods is likely a mistake, or just a leftover after a refactor.

Example

let collection = vec![1, 2, 3];
let iter = collection.iter().peekable();

for item in iter {
    // ...
}

Use instead:

let collection = vec![1, 2, 3];
let iter = collection.iter();

for item in iter {
    // ...
}