1 #![warn(clippy::option_map_unit_fn)]
4 fn do_nothing<T>(_: T) {}
6 fn diverge<T>(_: T) -> ! {
10 fn plus_one(value: usize) -> usize {
15 fn option_map_unit_fn() {
17 x.field.map(|value| { do_nothing(value); do_nothing(value) });
19 x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
21 // Suggestion for the let block should be `{ ... }` as it's too difficult to build a
22 // proper suggestion for these cases
27 x.field.map(|value| { do_nothing(value); do_nothing(value); });
29 // The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let variable name for them
30 Some(42).map(diverge);
31 "12".parse::<i32>().ok().map(diverge);
32 Some(plus_one(1)).map(do_nothing);
34 // Should suggest `if let Some(_y) ...` to not override the existing foo variable