From f2332a7da2bd9bfbe75fbd135e5fbf34d3eeed55 Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Sat, 21 Sep 2024 16:08:24 +0200 Subject: [PATCH] Fixed some Rust code structure and modified the workflow to fail if clippy returns warnings (#569) * Fixed someone else's mistakes * workflow now fails if clippy returns warnings * refactor: Make base title variable constant --------- Co-authored-by: Liam --- .github/workflows/rust.yml | 2 +- tui/src/state.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b42553c2..fd9e190e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -38,7 +38,7 @@ jobs: restore-keys: ${{ runner.os }}-cargo-index- - name: Run cargo clippy - run: cargo clippy + run: cargo clippy -- -Dwarnings - name: Run cargo fmt run: cargo fmt --all --check diff --git a/tui/src/state.rs b/tui/src/state.rs index 9bfb982f..dfc6787a 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -21,6 +21,7 @@ use ratatui::{ const MIN_WIDTH: u16 = 77; const MIN_HEIGHT: u16 = 19; +const TITLE: &str = concat!("Linux Toolbox - ", env!("BUILD_DATE")); pub struct AppState { /// Selected theme @@ -243,11 +244,11 @@ impl AppState { Style::new() }; - let title = format!( - "Linux Toolbox - {} {}", - env!("BUILD_DATE"), - self.multi_select.then(|| "[Multi-Select]").unwrap_or("") - ); + let title = if self.multi_select { + &format!("{} [Multi-Select]", TITLE) + } else { + TITLE + }; #[cfg(feature = "tips")] let bottom_title = Line::from(self.tip.bold().blue()).right_aligned();