From f70195905f86f3482af534dbcebf41d64a5d6d38 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:32:53 -0700 Subject: [PATCH 1/2] refactor: Modify theme in place --- src/state.rs | 8 ++++---- src/theme.rs | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/state.rs b/src/state.rs index 5e31b521..6345c4dc 100644 --- a/src/state.rs +++ b/src/state.rs @@ -196,8 +196,8 @@ impl AppState { self.refresh_tab(); } KeyCode::Char('/') => self.enter_search(), - KeyCode::Char('t') => self.theme = self.theme.next(), - KeyCode::Char('T') => self.theme = self.theme.prev(), + KeyCode::Char('t') => self.theme.next(), + KeyCode::Char('T') => self.theme.prev(), _ => {} }, Focus::List if key.kind != KeyEventKind::Release => match key.code { @@ -214,8 +214,8 @@ impl AppState { } KeyCode::Char('/') => self.enter_search(), KeyCode::Tab => self.focus = Focus::TabList, - KeyCode::Char('t') => self.theme = self.theme.next(), - KeyCode::Char('T') => self.theme = self.theme.prev(), + KeyCode::Char('t') => self.theme.next(), + KeyCode::Char('T') => self.theme.prev(), _ => {} }, _ => {} diff --git a/src/theme.rs b/src/theme.rs index bb5b6af2..9510fca1 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -87,16 +87,16 @@ impl Theme { impl Theme { #[allow(unused)] - pub fn next(self) -> Self { - let position = self as usize; + pub fn next(&mut self) { + let position = *self as usize; let types = Theme::value_variants(); - types[(position + 1) % types.len()].into() + *self = types[(position + 1) % types.len()]; } #[allow(unused)] - pub fn prev(self) -> Self { - let position = self as usize; + pub fn prev(&mut self) { + let position = *self as usize; let types = Theme::value_variants(); - types[(position + types.len() - 1) % types.len()].into() + *self = types[(position + types.len() - 1) % types.len()]; } } From 7bbde2a3425b6be8f4b87c21c95beb6f948f3999 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:33:56 -0700 Subject: [PATCH 2/2] refactor: Remove unnecessary allow_unused block --- src/theme.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/theme.rs b/src/theme.rs index 9510fca1..84fa15b4 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -86,14 +86,12 @@ impl Theme { } impl Theme { - #[allow(unused)] pub fn next(&mut self) { let position = *self as usize; let types = Theme::value_variants(); *self = types[(position + 1) % types.len()]; } - #[allow(unused)] pub fn prev(&mut self) { let position = *self as usize; let types = Theme::value_variants();