From 337f6b152132438aa22c739aa79dcb17d9c9e239 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 14 Mar 2026 17:18:39 +0100 Subject: [PATCH] Apply pedantic Clippy lints --- src/app_state.rs | 2 +- src/info_file.rs | 2 +- src/main.rs | 4 ++-- src/term.rs | 6 +++--- src/watch/state.rs | 2 +- src/watch/terminal_event.rs | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app_state.rs b/src/app_state.rs index a566e14b..ad63c6de 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -433,7 +433,7 @@ impl AppState { .is_err() { break; - }; + } let success = exercise.run_exercise(None, &slf.cmd_runner); let progress = match success { diff --git a/src/info_file.rs b/src/info_file.rs index 13206fd8..54a21a5c 100644 --- a/src/info_file.rs +++ b/src/info_file.rs @@ -23,7 +23,7 @@ pub struct ExerciseInfo { #[serde(default)] pub skip_check_unsolved: bool, } -#[inline(always)] +#[inline] const fn default_true() -> bool { true } diff --git a/src/main.rs b/src/main.rs index b541b68f..c39e8629 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,9 +171,9 @@ fn main() -> Result { stdout.write_all(b"\n")?; return Ok(ExitCode::FAILURE); - } else { - app_state.render_final_message(&mut stdout)?; } + + app_state.render_final_message(&mut stdout)?; } Some(Subcommands::Reset { name }) => { app_state.set_current_exercise_by_name(&name)?; diff --git a/src/term.rs b/src/term.rs index 96b8745a..65e4c511 100644 --- a/src/term.rs +++ b/src/term.rs @@ -197,15 +197,15 @@ pub fn progress_bar<'a>( total: u16, term_width: u16, ) -> io::Result<()> { - debug_assert!(total <= 999); - debug_assert!(progress <= total); - const PREFIX: &[u8] = b"Progress: ["; const PREFIX_WIDTH: u16 = PREFIX.len() as u16; const POSTFIX_WIDTH: u16 = "] xxx/xxx".len() as u16; const WRAPPER_WIDTH: u16 = PREFIX_WIDTH + POSTFIX_WIDTH; const MIN_LINE_WIDTH: u16 = WRAPPER_WIDTH + 4; + debug_assert!(total <= 999); + debug_assert!(progress <= total); + if term_width < MIN_LINE_WIDTH { writer.write_ascii(b"Progress: ")?; // Integers are in ASCII. diff --git a/src/watch/state.rs b/src/watch/state.rs index a92dd2d6..44cbd439 100644 --- a/src/watch/state.rs +++ b/src/watch/state.rs @@ -60,7 +60,7 @@ impl<'a> WatchState<'a> { watch_event_sender, terminal_event_unpause_receiver, manual_run, - ) + ); }) .context("Failed to spawn a thread to handle terminal events")?; diff --git a/src/watch/terminal_event.rs b/src/watch/terminal_event.rs index 2400a3df..439e4730 100644 --- a/src/watch/terminal_event.rs +++ b/src/watch/terminal_event.rs @@ -47,7 +47,7 @@ pub fn terminal_event_handler( // Pause input until quitting the confirmation prompt. if unpause_receiver.recv().is_err() { return; - }; + } continue; } @@ -64,7 +64,7 @@ pub fn terminal_event_handler( return; } } - Ok(Event::FocusGained | Event::FocusLost | Event::Mouse(_)) => continue, + Ok(Event::FocusGained | Event::FocusLost | Event::Mouse(_)) => (), Err(e) => break WatchEvent::TerminalEventErr(e), } };