From aa7fc940684320456f7cd178dad78a54df75f23e Mon Sep 17 00:00:00 2001 From: ede1998 Date: Sat, 29 Aug 2026 23:37:58 +0200 Subject: [PATCH] clippy fixes --- src/navigation/navigation.rs | 13 ++++++------- src/views/error_view.rs | 36 +++++++++++++++++------------------- src/views/flash_info_view.rs | 35 ++++++++++++++++------------------- 3 files changed, 39 insertions(+), 45 deletions(-) diff --git a/src/navigation/navigation.rs b/src/navigation/navigation.rs index d47dc78..b7aa9e0 100644 --- a/src/navigation/navigation.rs +++ b/src/navigation/navigation.rs @@ -1,4 +1,3 @@ -use crate::alloc::string::ToString; use crate::card::model::Card; use crate::navigation::inputs::ButtonAction; use crate::navigation::inputs::Inputs; @@ -9,6 +8,7 @@ use crate::views::error_view::ErrorView; use crate::views::view::View; use alloc::boxed::Box; use alloc::string::String; +use alloc::string::ToString; use core::error; use embassy_futures::select::{Either, select}; @@ -74,7 +74,7 @@ pub async fn run(mut inputs: Inputs, mut outputs: Outputs, peripherals: &'static .display(&mut outputs, peripherals) .await { - display_error(error.to_string(), &mut state, &mut outputs, &peripherals).await; + display_error(error.to_string(), &mut state, &mut outputs, peripherals).await; }; loop { @@ -120,16 +120,15 @@ pub async fn run(mut inputs: Inputs, mut outputs: Outputs, peripherals: &'static } state.screens.push(new_state.view); - if action != Action::Timer || new_state.redraw { - if let Err(error) = state + if (action != Action::Timer || new_state.redraw) + && let Err(error) = state .screens .last() .unwrap() .display(&mut outputs, peripherals) .await - { - display_error(error.to_string(), &mut state, &mut outputs, &peripherals).await; - } + { + display_error(error.to_string(), &mut state, &mut outputs, peripherals).await; } Timer::after(Duration::from_millis(DEBOUNCE_DURATION_MILLIS)).await; diff --git a/src/views/error_view.rs b/src/views/error_view.rs index 999e090..14711a9 100644 --- a/src/views/error_view.rs +++ b/src/views/error_view.rs @@ -5,8 +5,8 @@ use crate::navigation::outputs::Outputs; use crate::peripherals::Peripherals; use crate::views::view::View; use alloc::boxed::Box; -use alloc::format; use alloc::string::String; +use alloc::string::ToString; use core::error; use embedded_graphics::{ Drawable, @@ -57,7 +57,7 @@ impl Navigable for ErrorView { let bounds = Rectangle::new(Point::new(0, 30), display_area.size); - TextBox::with_textbox_style(&format!("{}", self.error), bounds, style, textbox_style) + TextBox::with_textbox_style(&self.error.to_string(), bounds, style, textbox_style) .draw(&mut outputs.primary_display) .unwrap_or_else(|error| { panic!( @@ -71,23 +71,21 @@ impl Navigable for ErrorView { fn handle_input(&self, input: Action) -> impl core::future::Future + Send { async move { - let Action::Button(input) = input else { - // Skip timer inputs - return NewState { - view: View::Error(self.clone()), - replace_view: true, - redraw: false, - }; - }; - - let new_menu = match input { - _ => View::Error(self.clone()), - }; - - NewState { - replace_view: matches!(new_menu, View::FlashInfo(_)), - view: new_menu, - redraw: true, + let new_menu = View::Error(self.clone()); + match input { + Action::Button(_) => NewState { + replace_view: matches!(new_menu, View::FlashInfo(_)), + view: new_menu, + redraw: true, + }, + Action::Timer => { + // Skip timer inputs + NewState { + view: new_menu, + replace_view: true, + redraw: false, + } + } } } } diff --git a/src/views/flash_info_view.rs b/src/views/flash_info_view.rs index e9ccb02..54a0bc6 100644 --- a/src/views/flash_info_view.rs +++ b/src/views/flash_info_view.rs @@ -16,7 +16,6 @@ use embedded_graphics::{ pixelcolor::Rgb565, prelude::*, primitives::Rectangle, - text::Text, }; use alloc::format; @@ -35,7 +34,7 @@ impl Navigable for FlashInfoView { peripherals: &Peripherals, ) -> impl core::future::Future>> + Send { async move { - let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE); + let _style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE); let mut magic_bytes: [u8; MAGIC_REGION.size] = [0; MAGIC_REGION.size]; peripherals .store @@ -83,23 +82,21 @@ Card Count: {}\n fn handle_input(&self, input: Action) -> impl core::future::Future + Send { async move { - let Action::Button(input) = input else { - // Skip timer inputs - return NewState { - view: View::FlashInfo(self.clone()), - replace_view: true, - redraw: false, - }; - }; - - let new_menu = match input { - _ => View::FlashInfo(self.clone()), - }; - - NewState { - replace_view: matches!(new_menu, View::FlashInfo(_)), - view: new_menu, - redraw: true, + let new_menu = View::FlashInfo(self.clone()); + match input { + Action::Button(_) => NewState { + replace_view: matches!(new_menu, View::FlashInfo(_)), + view: new_menu, + redraw: true, + }, + Action::Timer => { + // Skip timer inputs + NewState { + view: new_menu, + replace_view: true, + redraw: false, + } + } } } }