rust/tests/ui/map_all_any_identity.fixed

22 lines
492 B
Rust
Raw Normal View History

2024-10-04 17:03:07 -05:00
#![warn(clippy::map_all_any_identity)]
fn main() {
let _ = ["foo"].into_iter().any(|s| s == "foo");
//~^ map_all_any_identity
let _ = ["foo"].into_iter().all(|s| s == "foo");
//~^ map_all_any_identity
//
// Do not lint
//
// Not identity
let _ = ["foo"].into_iter().map(|s| s.len()).any(|n| n > 0);
// Macro
macro_rules! map {
($x:expr) => {
$x.into_iter().map(|s| s == "foo")
};
}
map!(["foo"]).any(|a| a);
}