]> git.lizzy.rs Git - rust.git/blob - tests/ui/result_map_unwrap_or_else.rs
Auto merge of #4314 - chansuke:add-negation-to-is_empty, r=flip1995
[rust.git] / tests / ui / result_map_unwrap_or_else.rs
1 // aux-build:option_helpers.rs
2
3 //! Checks implementation of `RESULT_MAP_UNWRAP_OR_ELSE`
4
5 #![warn(clippy::result_map_unwrap_or_else)]
6
7 #[macro_use]
8 extern crate option_helpers;
9
10 fn result_methods() {
11     let res: Result<i32, ()> = Ok(1);
12
13     // Check RESULT_MAP_UNWRAP_OR_ELSE
14     // single line case
15     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
16                                                       // multi line cases
17     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
18     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
19     // macro case
20     let _ = opt_map!(res, |x| x + 1).unwrap_or_else(|e| 0); // should not lint
21 }
22
23 fn main() {}