From f0d3cd10c587936e54aaf1b2dae23a40dc0265b4 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 2 Feb 2023 13:23:05 -0330 Subject: make input handling match expression more concise --- Cargo.lock | 2 +- src/input.rs | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97307e7..0a7e7c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "pfc" -version = "0.1.0" +version = "0.2.0" dependencies = [ "crossterm", "tui", diff --git a/src/input.rs b/src/input.rs index 01d0b11..30262d2 100644 --- a/src/input.rs +++ b/src/input.rs @@ -15,15 +15,9 @@ impl Calculator { KeyCode::Char('q') => { return Signal::Exit; } - KeyCode::Char('j' | 'k') => { - self.swap(); - } - KeyCode::Char(c) => { - self.push_to_buffer(c); - } - KeyCode::Enter => { - self.push_buffer_to_stack(); - } + KeyCode::Char('j' | 'k') => self.swap(), + KeyCode::Char(c) => self.push_to_buffer(c), + KeyCode::Enter => self.push_buffer_to_stack(), KeyCode::Backspace => { self.input_buffer.pop(); } -- cgit v1.2.3