From 52b383be7879e8aa6ef92721c0a145cec50fee3d Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Wed, 5 Aug 2026 20:02:50 -0400 Subject: [PATCH] clippy cleanups --- src/main.rs | 5 +++-- src/ui.rs | 13 ++++++------- src/workflow.rs | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index a9dd0b9..af753f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ mod workflow; use crate::cli::Command; use crate::nix::EvaluationProgress; +use crate::ui::Ui; #[tokio::main] async fn main() -> anyhow::Result<()> { @@ -30,7 +31,7 @@ async fn main() -> anyhow::Result<()> { ui.start_job(&evaluation, &name, &name); } EvaluationProgress::MetadataResolved { name } => { - ui.finish_job_success(ui.job_progress(&evaluation, &name), &name); + ui.finish_job_success(Ui::job_progress(&evaluation, &name), &name); } }) .await; @@ -48,7 +49,7 @@ async fn main() -> anyhow::Result<()> { match args.command { Command::List => { - ui.print_nodes(&jobs); + Ui::print_nodes(&jobs); return Ok(()); } cmd @ (Command::Switch(_) | Command::Boot(_)) => { diff --git a/src/ui.rs b/src/ui.rs index 19a1274..af80402 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -32,7 +32,7 @@ impl Ui { } } - pub fn print_nodes(&self, jobs: &HashMap) { + pub fn print_nodes(jobs: &HashMap) { let mut nodes: Vec<_> = jobs.iter().collect(); nodes.sort_by_key(|(name, _)| *name); @@ -41,7 +41,7 @@ impl Ui { } } - pub fn print_warning(&self, message: impl Display) { + pub fn print_warning(message: impl Display) { eprintln!("{}", warning(format!("! {message}"))); } @@ -91,20 +91,19 @@ impl Ui { progress } - pub fn finish_job_success(&self, progress: ProgressBar, name: &str) { + pub fn finish_job_success(&self, progress: &ProgressBar, name: &str) { self.finish_job(progress, format!(" {} {name}", success_marker())); } - pub fn finish_job_failure(&self, progress: ProgressBar, name: &str, error: impl Display) { + pub fn finish_job_failure(&self, progress: &ProgressBar, name: &str, error: impl Display) { self.finish_job(progress, format!(" {} {name}: {error}", failure_marker())); } - pub fn job_progress(&self, section: &SectionProgress, name: &str) -> ProgressBar { + pub fn job_progress<'a>(section: &'a SectionProgress, name: &str) -> &'a ProgressBar { section .jobs .get(name) .expect("job progress must be registered") - .clone() } pub fn finish_section_success(&self, section: SectionProgress) { @@ -143,7 +142,7 @@ impl Ui { progress } - fn finish_job(&self, progress: ProgressBar, message: String) { + fn finish_job(&self, progress: &ProgressBar, message: String) { if self.is_interactive { progress.set_style(completed_style()); progress.finish_with_message(message); diff --git a/src/workflow.rs b/src/workflow.rs index a865a64..aa5f613 100644 --- a/src/workflow.rs +++ b/src/workflow.rs @@ -19,7 +19,7 @@ pub async fn run_deploy( ) -> anyhow::Result<()> { let (jobs, unknown_skips) = filter_jobs(jobs, &common)?; for name in unknown_skips { - ui.print_warning(format!("ignoring unknown node '{name}' in --skip")); + Ui::print_warning(format!("ignoring unknown node '{name}' in --skip")); } op::validate(&jobs, operation)?; @@ -88,11 +88,11 @@ async fn build_closures( let result = nix::build_closure(&jobs[&name], &common.build_host, host_key_policy).await; match result { Ok(closure) => { - ui.finish_job_success(job_progress, &name); + ui.finish_job_success(&job_progress, &name); closures.insert(name, closure); } Err(error) => { - ui.finish_job_failure(job_progress, &name, &error); + ui.finish_job_failure(&job_progress, &name, &error); ui.finish_section_failure(progress); return Err(error).context(format!("building {name}")); } @@ -126,8 +126,8 @@ async fn deploy_closures( let job_progress = ui.start_job(deployment_section, &name, &label); let result = nix::deploy_closure(&spec, &closure, operation, host_key_policy).await; match &result { - Ok(()) => ui.finish_job_success(job_progress, &label), - Err(error) => ui.finish_job_failure(job_progress, &label, error), + Ok(()) => ui.finish_job_success(&job_progress, &label), + Err(error) => ui.finish_job_failure(&job_progress, &label, error), } result } -- 2.51.2