RS.CLIPPY.SUSPICIOUS_MAP

Suspicious usage of map

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

What it does

Checks for calls to map followed by a count.

Why is this bad?

It looks suspicious. Maybe map was confused with filter. If the map call is intentional, this should be rewritten using inspect. Or, if you intend to drive the iterator to completion, you can just use for_each instead.

Example

let _ = (0..3).map(|x| x + 2).count();