RS.CLIPPY.WHILE_LET_ON_ITERATOR

Using a `while let` loop instead of a for loop on an iterator

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

What it does

Checks for while let expressions on iterators.

Why is this bad?

Readability. A simple for loop is shorter and conveys the intent better.

Example

while let Some(val) = iter.next() {
    ..
}

Use instead:

for val in &mut iter {
    ..
}