2 #![warn(clippy::option_if_let_else)]
4 fn bad1(string: Option<&str>) -> (bool, &str) {
5 string.map_or((false, "hello"), |x| (true, x))
8 fn bad2(string: Option<&str>) -> Option<(bool, &str)> {
11 } else { string.map_or(Some((false, "")), |x| Some((true, x))) }
14 fn longer_body(arg: Option<u32>) -> u32 {
21 fn test_map_or_else(arg: Option<u32>) {
22 let _ = arg.map_or_else(|| {
27 }, |x| x * x * x * x);
30 fn negative_tests(arg: Option<u32>) -> u32 {
31 let _ = if let Some(13) = arg { "unlucky" } else { "lucky" };
33 let _ = if let Some(x) = arg {
39 let _ = if let Some(x) = arg {
48 let optional = Some(5);
49 let _ = optional.map_or(5, |x| x + 2);
52 let _ = longer_body(None);
53 test_map_or_else(None);
54 let _ = negative_tests(None);