]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/option_map_or_none.fixed
New upstream version 1.59.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / option_map_or_none.fixed
CommitLineData
f20569fa
XL
1// run-rustfix
2
3#![allow(clippy::bind_instead_of_map)]
4
5fn main() {
6 let opt = Some(1);
a2a8927a
XL
7 let r: Result<i32, i32> = Ok(1);
8 let bar = |_| Some(1);
f20569fa
XL
9
10 // Check `OPTION_MAP_OR_NONE`.
11 // Single line case.
a2a8927a 12 let _: Option<i32> = opt.map(|x| x + 1);
f20569fa
XL
13 // Multi-line case.
14 #[rustfmt::skip]
a2a8927a
XL
15 let _: Option<i32> = opt.map(|x| x + 1);
16 // function returning `Option`
17 let _: Option<i32> = opt.and_then(bar);
18 let _: Option<i32> = opt.and_then(|x| {
19 let offset = 0;
20 let height = x;
21 Some(offset + height)
22 });
23
24 // Check `RESULT_MAP_OR_INTO_OPTION`.
25 let _: Option<i32> = r.ok();
f20569fa 26}