RS.CLIPPY.UNUSED_ENUMERATE_INDEX

Using `.enumerate()` and immediately dropping the index

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_enumerate_index. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for uses of the enumerate method where the index is unused (_)

Why is this bad?

The index from .enumerate() is immediately dropped.

Example

let v = vec![1, 2, 3, 4];
for (_, x) in v.iter().enumerate() {
    println!("{x}");
}

Use instead:

let v = vec![1, 2, 3, 4];
for x in v.iter() {
    println!("{x}");
}