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 | pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> { | 100 | pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> { |
| 101 | use io::ErrorKind; | 101 | use io::ErrorKind; |
| 102 | - match action { | 102 | + if let KeyAction::Spawn = action { |
| 103 | - KeyAction::Spawn => match arg { | 103 | + match arg { |
| 104 | Arg::Str(command) => match Command::new(command).spawn() { | 104 | Arg::Str(command) => match Command::new(command).spawn() { |
| 105 | Err(err) if err.kind() == ErrorKind::NotFound => { | 105 | Err(err) if err.kind() == ErrorKind::NotFound => { |
| 106 | eprintln!( | 106 | eprintln!( |
| @@ -128,8 +128,7 @@ pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> { | |||
| 128 | } | 128 | } |
| 129 | } | 129 | } |
| 130 | _ => {} | 130 | _ => {} |
| 131 | - }, | 131 | + } |
| 132 | - _ => {} | ||
| 133 | } | 132 | } |
| 134 | 133 | ||
| 135 | Ok(()) | 134 | Ok(()) |