simplify `handle_spawn_action` with if-let instead of match
Browse files
replaced single branch match with if-let
+3 −4 src/keyboard/handlers.rs
| @@ -99,8 +99,8 @@ pub fn handle_key_press(event: KeyPressEvent, keybindings: &[Key]) -> (KeyAction | ||
| 99 | 99 | |
| 100 | 100 | pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> { |
| 101 | 101 | use io::ErrorKind; |
| 102 | - match action { | |
| 103 | - KeyAction::Spawn => match arg { | |
| 102 | + if let KeyAction::Spawn = action { | |
| 103 | + match arg { | |
| 104 | 104 | Arg::Str(command) => match Command::new(command).spawn() { |
| 105 | 105 | Err(err) if err.kind() == ErrorKind::NotFound => { |
| 106 | 106 | eprintln!( |
| @@ -128,8 +128,7 @@ pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> { | ||
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | _ => {} |
| 131 | - }, | |
| 132 | - _ => {} | |
| 131 | + } | |
| 133 | 132 | } |
| 134 | 133 | |
| 135 | 134 | Ok(()) |