RS.CLIPPY.MAP_ALL_ANY_IDENTITY

Combine `.map(_)` followed by `.all(identity)`/`.any(identity)` into a single call

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

What it does

Checks for usage of .map(...), followed by .all(identity) or .any(identity).

Why is this bad?

The .all(...) or .any(...) methods can be called directly in place of .map(...).

Example

let e1 = v.iter().map(|s| s.is_empty()).all(|a| a);
let e2 = v.iter().map(|s| s.is_empty()).any(std::convert::identity);

Use instead:

let e1 = v.iter().all(|s| s.is_empty());
let e2 = v.iter().any(|s| s.is_empty());