RS.CLIPPY.MANUAL_CONTAINS
Unnecessary `iter().any()` on slices that can be replaced with `contains()`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: manual_contains. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of iter().any() on slices when it can be replaced with contains() and suggests doing so.
Why is this bad?
contains() is more concise and idiomatic, while also being faster in some cases.
Example
fn foo(values: &[u8]) -> bool {
values.iter().any(|&v| v == 10)
}
Use instead:
fn foo(values: &[u8]) -> bool {
values.contains(&10)
}