Fix some clippy lints #52

Merged
ede1998 merged 1 commits from clippy into main 2026-08-29 23:42:45 +02:00
3 changed files with 39 additions and 45 deletions
+5 -6
View File
@@ -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;
+14 -16
View File
@@ -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<Output = NewState> + 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 {
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,
}
}
}
}
}
+13 -16
View File
@@ -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<Output = Result<(), Box<dyn error::Error>>> + 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<Output = NewState> + 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 {
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,
}
}
}
}
}