From a19d4cd818fe7b8788a61431c864599891da74fe Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:41:38 -0400 Subject: [PATCH] chore: apply clippy lint suggestions warning: redundant field names in struct initialization --> src/cmd/validate.rs:371:13 | 371 | cache_age_secs: cache_age_secs, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `cache_age_secs` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names = note: `#[warn(clippy::redundant_field_names)]` on by default warning: redundant field names in struct initialization --> src/cmd/validate.rs:375:13 | 375 | ckan_token: ckan_token, | ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `ckan_token` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names warning: using `clone` on type `Option` which implements the `Copy` trait --> src/cmd/validate.rs:362:13 | 362 | delim.clone() | ^^^^^^^^^^^^^ help: try dereferencing it: `*delim` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy = note: `#[warn(clippy::clone_on_copy)]` on by default warning: the borrowed expression implements the required traits --> src/lookup.rs:43:41 | 43 | let expanded_dir = expand_tilde(&cache_dir).unwrap(); | ^^^^^^^^^^ help: change this to: `cache_dir` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default --- src/cmd/validate.rs | 6 +++--- src/lookup.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmd/validate.rs b/src/cmd/validate.rs index 201b5c338..4f261e854 100644 --- a/src/cmd/validate.rs +++ b/src/cmd/validate.rs @@ -359,7 +359,7 @@ fn dyn_enum_validator_factory<'a>( }; let delimiter = if let Some(delim) = DELIMITER.get() { - delim.clone() + *delim } else { None }; @@ -368,11 +368,11 @@ fn dyn_enum_validator_factory<'a>( let opts = LookupTableOptions { name: lookup_name, uri: uri.clone(), - cache_age_secs: cache_age_secs, + cache_age_secs, cache_dir: QSV_CACHE_DIR.get().unwrap().to_string(), delimiter, ckan_api_url: CKAN_API.get().cloned(), - ckan_token: ckan_token, + ckan_token, timeout_secs: TIMEOUT_SECS.load(Ordering::Relaxed), }; diff --git a/src/lookup.rs b/src/lookup.rs index 46968d6f8..6747b1fd3 100644 --- a/src/lookup.rs +++ b/src/lookup.rs @@ -40,7 +40,7 @@ pub fn set_qsv_cache_dir(cache_dir: &str) -> Result { } } else if cache_dir.starts_with('~') { // expand the tilde - let expanded_dir = expand_tilde(&cache_dir).unwrap(); + let expanded_dir = expand_tilde(cache_dir).unwrap(); expanded_dir.to_string_lossy().to_string() } else { cache_dir.to_string()