From cc0fdab90d959bab82ca8eb2c8827cad84fc6cce Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Jun 2024 14:25:55 -0400 Subject: [PATCH] tree-wide: Fix minor clippy lints We had an unused variable...should probably start denying that in CI. Fix a few other style things while we have the patient open. Signed-off-by: Colin Walters --- lib/src/cli.rs | 5 ++--- lib/src/kargs.rs | 2 +- lib/src/status.rs | 17 ++++++++--------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index ccfb87a99..f4b4077fc 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -17,7 +17,6 @@ use fn_error_context::context; use ostree::gio; use ostree_container::store::PrepareResult; use ostree_ext::container as ostree_container; -use ostree_ext::container::Transport; use ostree_ext::keyfileext::KeyFileExt; use ostree_ext::ostree; @@ -113,9 +112,9 @@ pub(crate) struct EditOpts { #[clap(rename_all = "lowercase")] pub(crate) enum OutputFormat { /// Output in YAML format. - YAML, + Yaml, /// Output in JSON format. - JSON, + Json, } /// Perform an status operation diff --git a/lib/src/kargs.rs b/lib/src/kargs.rs index d06be2562..63b97422c 100644 --- a/lib/src/kargs.rs +++ b/lib/src/kargs.rs @@ -44,7 +44,7 @@ pub(crate) fn get_kargs_in_root(d: &Dir, sys_arch: &str) -> Result> // Read all the entries let mut entries = d.entries()?.collect::>>()?; // cc https://github.com/rust-lang/rust/issues/85573 re the allocation-per-comparison here - entries.sort_by(|a, b| a.file_name().cmp(&b.file_name())); + entries.sort_by_key(|a| a.file_name()); for ent in entries { let name = ent.file_name(); let name = name diff --git a/lib/src/status.rs b/lib/src/status.rs index c64a05594..59ab31f85 100644 --- a/lib/src/status.rs +++ b/lib/src/status.rs @@ -318,16 +318,15 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> { // Filter to just the serializable status structures. let out = std::io::stdout(); let mut out = out.lock(); - let format = opts.format.unwrap_or_else(|| { - if opts.json { - OutputFormat::JSON - } else { - OutputFormat::YAML - } - }); + let legacy_opt = if opts.json { + OutputFormat::Json + } else { + OutputFormat::Yaml + }; + let format = opts.format.unwrap_or(legacy_opt); match format { - OutputFormat::JSON => serde_json::to_writer(&mut out, &host).map_err(anyhow::Error::new), - OutputFormat::YAML => serde_yaml::to_writer(&mut out, &host).map_err(anyhow::Error::new), + OutputFormat::Json => serde_json::to_writer(&mut out, &host).map_err(anyhow::Error::new), + OutputFormat::Yaml => serde_yaml::to_writer(&mut out, &host).map_err(anyhow::Error::new), } .context("Writing to stdout")?;