RS.CLIPPY.UNNECESSARY_FOLD
Using `fold` when a more succinct alternative exists
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unnecessary_fold. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of fold when a more succinct alternative exists.
Specifically, this checks for folds which could be replaced by any, all,
sum or product.
Why is this bad?
Readability.
Example
(0..3).fold(false, |acc, x| acc || x > 2);
Use instead:
(0..3).any(|x| x > 2);