]> git.lizzy.rs Git - rust.git/blob - tests/ui/filter_map_next.rs
Auto merge of #5980 - matsujika:create-dir, r=flip1995
[rust.git] / tests / ui / filter_map_next.rs
1 #![warn(clippy::all, clippy::pedantic)]
2
3 fn main() {
4     let a = ["1", "lol", "3", "NaN", "5"];
5
6     let element: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
7     assert_eq!(element, Some(1));
8
9     #[rustfmt::skip]
10     let _: Option<u32> = vec![1, 2, 3, 4, 5, 6]
11         .into_iter()
12         .filter_map(|x| {
13             if x == 2 {
14                 Some(x * 2)
15             } else {
16                 None
17             }
18         })
19         .next();
20 }