]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/unnecessary_find_map.rs
4 let _
= (0..4).find_map(|x
| if x
> 1 { Some(x) }
else { None }
);
5 //~^ ERROR: this `.find_map` can be written more simply using `.find`
6 //~| NOTE: `-D clippy::unnecessary-find-map` implied by `-D warnings`
7 let _
= (0..4).find_map(|x
| {
8 //~^ ERROR: this `.find_map` can be written more simply using `.find`
14 let _
= (0..4).find_map(|x
| match x
{
15 //~^ ERROR: this `.find_map` can be written more simply using `.find`
20 let _
= (0..4).find_map(|x
| Some(x
+ 1));
21 //~^ ERROR: this `.find_map` can be written more simply using `.map(..).next()`
23 let _
= (0..4).find_map(i32::checked_abs
);
26 fn find_map_none_changes_item_type() -> Option
<bool
> {
27 "".chars().find_map(|_
| None
)
32 let _x
= std
::iter
::once(1).find_map(|n
| (n
> 1).then_some(n
));
33 let _x
= std
::iter
::once(1).find_map(|n
| (n
> 1).then_some(y
)); // different option, so can't be just `.find()`