From e04d8970066d4c6c51abd74a5e3edb174a3da319 Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Thu, 15 Aug 2024 15:59:50 +0200 Subject: [PATCH] fix: clippy issues --- src/bin/generate-cli-docs.rs | 2 +- src/tui/render.rs | 27 ++++++++++++--------------- src/tui/state.rs | 4 ++-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/bin/generate-cli-docs.rs b/src/bin/generate-cli-docs.rs index a6ce8399..7a4ac65d 100644 --- a/src/bin/generate-cli-docs.rs +++ b/src/bin/generate-cli-docs.rs @@ -12,7 +12,7 @@ fn main() { let target_default_platform = format!("Default value: `{}`", Platform::current()); let help = help.replace( target_default_platform.as_str(), - format!("Default value: current platform").as_str(), + "Default value: current platform", ); print!("{}", help); diff --git a/src/tui/render.rs b/src/tui/render.rs index e8051c3e..85e15911 100644 --- a/src/tui/render.rs +++ b/src/tui/render.rs @@ -1,24 +1,21 @@ -use super::event::Event; -use super::state::TuiState; use ansi_to_tui::IntoText; use crossterm::event::{ Event as CrosstermEvent, KeyCode, KeyEvent, KeyModifiers, MouseButton, MouseEvent, MouseEventKind, }; use miette::IntoDiagnostic; -use ratatui::layout::Position; -use ratatui::prelude::*; -use ratatui::style::Stylize; -use ratatui::widgets::{Scrollbar, ScrollbarOrientation, ScrollbarState}; use ratatui::{ - layout::Alignment, - style::{Color, Style}, - widgets::{Block, BorderType, Paragraph}, + layout::{Alignment, Position}, + prelude::*, + style::{Color, Style, Stylize}, + widgets::{Block, BorderType, Paragraph, Scrollbar, ScrollbarOrientation, ScrollbarState}, Frame, }; use tokio::sync::mpsc; use tui_input::backend::crossterm::EventHandler; +use super::{event::Event, state::TuiState}; + /// Key bindings. const KEY_BINDINGS: &[(&str, &str)] = &[ ("⏎ ", "Build"), @@ -263,12 +260,12 @@ pub(crate) fn render_widgets(state: &mut TuiState, frame: &mut Frame) { package.name.clone().into(), "-".fg(Color::Rgb(100, 100, 100)), package.version.clone().into(), - package - .build_string - .clone() - .map(|v| format!("{}{v}", "-".fg(Color::Rgb(100, 100, 100)))) - .unwrap_or_default() - .into(), + format!( + "{}{}", + "-".fg(Color::Rgb(100, 100, 100)), + &package.build_string + ) + .into(), ]); if item[1].width < line.width() as u16 { line = Line::from(vec![ diff --git a/src/tui/state.rs b/src/tui/state.rs index afd89464..1b785b94 100644 --- a/src/tui/state.rs +++ b/src/tui/state.rs @@ -14,7 +14,7 @@ use crate::{ pub struct Package { pub name: String, pub version: String, - pub build_string: Option, + pub build_string: String, pub subpackages: Vec, pub build_progress: BuildProgress, pub build_log: Vec, @@ -33,7 +33,7 @@ impl Package { Package { name: name.clone(), version: output.version().to_string(), - build_string: output.build_string().map(String::from), + build_string: output.build_string().into_owned(), subpackages: output .build_configuration .subpackages