From 81f1f8ee60c534ed0467f68f91249c6b23aaaa5b Mon Sep 17 00:00:00 2001 From: kjuulh Date: Thu, 9 May 2024 17:25:52 +0200 Subject: [PATCH] chore: make clippy happy Signed-off-by: kjuulh --- crates/hyperlog-tui/src/app.rs | 7 ++----- crates/hyperlog-tui/src/app/dialog.rs | 20 +++++++------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/crates/hyperlog-tui/src/app.rs b/crates/hyperlog-tui/src/app.rs index ca51b0f..eee5529 100644 --- a/crates/hyperlog-tui/src/app.rs +++ b/crates/hyperlog-tui/src/app.rs @@ -4,11 +4,8 @@ use ratatui::{ }; use crate::{ - command_parser::{CommandParser, Commands}, - commands::IntoCommand, - components::GraphExplorer, - state::SharedState, - Msg, + command_parser::CommandParser, commands::IntoCommand, components::GraphExplorer, + state::SharedState, Msg, }; use self::{ diff --git a/crates/hyperlog-tui/src/app/dialog.rs b/crates/hyperlog-tui/src/app/dialog.rs index e5ac565..ee10e76 100644 --- a/crates/hyperlog-tui/src/app/dialog.rs +++ b/crates/hyperlog-tui/src/app/dialog.rs @@ -68,12 +68,13 @@ impl BufferState { } } +#[derive(Default)] pub struct InputBuffer { pub state: BufferState, } impl InputBuffer { - fn to_focused(&mut self) { + fn transform_focused(&mut self) { match &mut self.state { BufferState::Focused { .. } => {} BufferState::Static { content, position } => { @@ -85,7 +86,7 @@ impl InputBuffer { } } - fn to_static(&mut self) { + fn transform_static(&mut self) { match &mut self.state { BufferState::Focused { content, position } => { self.state = BufferState::Static { @@ -97,6 +98,7 @@ impl InputBuffer { } } + #[allow(dead_code)] pub fn toggle(&mut self) { match &mut self.state { BufferState::Focused { content, position } => { @@ -116,9 +118,9 @@ impl InputBuffer { pub fn update(&mut self, msg: &Msg) -> anyhow::Result<()> { match msg { - Msg::EnterInsertMode => self.to_focused(), - Msg::EnterCommandMode => self.to_focused(), - Msg::EnterViewMode => self.to_static(), + Msg::EnterInsertMode => self.transform_focused(), + Msg::EnterCommandMode => self.transform_focused(), + Msg::EnterViewMode => self.transform_static(), Msg::Edit(c) => { self.state.update(c)?; } @@ -136,14 +138,6 @@ impl InputBuffer { } } -impl Default for InputBuffer { - fn default() -> Self { - Self { - state: BufferState::default(), - } - } -} - pub struct InputField<'a> { title: &'a str,