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