]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/result_map_or_into_option.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / result_map_or_into_option.rs
1 #![warn(clippy::result_map_or_into_option)]
2
3 fn main() {
4 let opt: Result<u32, &str> = Ok(1);
5 let _ = opt.map_or(None, Some);
6
7 let rewrap = |s: u32| -> Option<u32> { Some(s) };
8
9 // A non-Some `f` arg should not emit the lint
10 let opt: Result<u32, &str> = Ok(1);
11 let _ = opt.map_or(None, rewrap);
12
13 // A non-Some `f` closure where the argument is not used as the
14 // return should not emit the lint
15 let opt: Result<u32, &str> = Ok(1);
16 _ = opt.map_or(None, |_x| Some(1));
17 }