RS.CLIPPY.FOR_KV_MAP

Looping on a map using `iter` when `keys` or `values` would do

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

What it does

Checks for iterating a map (HashMap or BTreeMap) and ignoring either the keys or values.

Why is this bad?

Readability. There are keys and values methods that can be used to express that don't need the values or keys.

Example

for (k, _) in &map {
    ..
}

could be replaced by

for k in map.keys() {
    ..
}