2 // aux-build:option_helpers.rs
4 #![warn(clippy::map_unwrap_or)]
7 extern crate option_helpers;
9 use std::collections::HashMap;
15 // Check for `option.map(_).unwrap_or_else(_)` use.
17 let _ = opt.map(|x| x + 1)
18 // Should lint even though this call is on a separate line.
19 .unwrap_or_else(|| 0);
23 let _ = opt_map!(opt, |x| x + 1).unwrap_or_else(|| 0);
27 let mut frequencies = HashMap::new();
36 frequencies.insert(word.to_owned(), 1);
43 let res: Result<i32, ()> = Ok(1);
45 // Check for `result.map(_).unwrap_or_else(_)` use.
47 let _ = res.map(|x| x + 1)
48 // should lint even though this call is on a separate line
49 .unwrap_or_else(|_e| 0);
52 let _ = opt_map!(res, |x| x + 1).unwrap_or_else(|_e| 0); // should not lint