oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git

simplify `handle_spawn_action` with if-let instead of match

Commit
fe6d8c84dd612516e25ca5b7c2e49744da584b24
Parent
fa60658
Author
emzywastaken <amiamemetoo@gmail.com>
Date
2025-10-14 19:13:45
replaced single branch match with if-let

Diff

diff --git a/src/keyboard/handlers.rs b/src/keyboard/handlers.rs
index a97d9e4..52142a3 100644
--- a/src/keyboard/handlers.rs
+++ b/src/keyboard/handlers.rs
@@ -99,8 +99,8 @@ pub fn handle_key_press(event: KeyPressEvent, keybindings: &[Key]) -> (KeyAction
 
 pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> {
     use io::ErrorKind;
-    match action {
-        KeyAction::Spawn => match arg {
+    if let KeyAction::Spawn = action {
+        match arg {
             Arg::Str(command) => match Command::new(command).spawn() {
                 Err(err) if err.kind() == ErrorKind::NotFound => {
                     eprintln!(
@@ -128,8 +128,7 @@ pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> {
                 }
             }
             _ => {}
-        },
-        _ => {}
+        }
     }
 
     Ok(())