]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // run-rustfix |
2 | ||
3 | #![warn(clippy::all, clippy::pedantic)] | |
4 | #![allow(clippy::let_underscore_drop)] | |
5 | #![allow(clippy::missing_docs_in_private_items)] | |
6 | #![allow(clippy::map_identity)] | |
7 | #![allow(clippy::unnecessary_wraps)] | |
8 | ||
9 | fn main() { | |
10 | // mapping to Option on Iterator | |
11 | fn option_id(x: i8) -> Option<i8> { | |
12 | Some(x) | |
13 | } | |
14 | let option_id_ref: fn(i8) -> Option<i8> = option_id; | |
15 | let option_id_closure = |x| Some(x); | |
16 | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id).collect(); | |
17 | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id_ref).collect(); | |
18 | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id_closure).collect(); | |
19 | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(|x| x.checked_add(1)).collect(); | |
20 | ||
21 | // mapping to Iterator on Iterator | |
22 | let _: Vec<_> = vec![5_i8; 6].into_iter().flat_map(|x| 0..x).collect(); | |
23 | ||
24 | // mapping to Option on Option | |
25 | let _: Option<_> = (Some(Some(1))).and_then(|x| x); | |
26 | } |