Code Example Template
match action {
    ShortcutAction::Remap(code) => press(code),
    _ => default_behavior(),
}

Deep-Dive System Documentation

Pattern Matching: Structural Dispatch

The match expression is Rust's most powerful branching primitive. It destructures complex algebraic patterns and ensures absolute correctness at compile time.

Key Mechanics

  1. Exhaustive Matching: Every single possible value of the matched type must be resolved, or the compiler will refuse to compile.
  2. Wildcard (_): Catches any remaining variants or values.
enum State { Active, Idle, Terminated }

match system_state {
    State::Active => start_hook(),
    State::Idle => sleep(50),
    State::Terminated => cleanup(), // all variants handled!
}

Destructuring Inner Values

If an enum carries data, match lets you extract the variables directly within the branch:

match action {
    ShortcutAction::Remap(vk_code) => emit_raw(vk_code),
    ShortcutAction::RunScript(path) => run_shell(path),
    _ => {}
}

Quick Reference Guide

match val {
    1 => println!("one"),
    _ => println!("other"),
}