From b49bcb7a167c846541dcc97b4078370d6a6a923d Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Sat, 5 Apr 2025 00:14:17 +1000 Subject: [PATCH] Fix clippy lints (#2111) * Fix indentation of docs in extracted_files.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Optimize parse_header_retry_after Use next_back instead of last Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix doc indentation in cargo_config.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --------- Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --- .../src/download/extracted_files.rs | 18 +++++++++--------- crates/binstalk-downloader/src/remote.rs | 2 +- crates/binstalk-manifests/src/cargo_config.rs | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/binstalk-downloader/src/download/extracted_files.rs b/crates/binstalk-downloader/src/download/extracted_files.rs index bf4c0f8a..ac45d4fb 100644 --- a/crates/binstalk-downloader/src/download/extracted_files.rs +++ b/crates/binstalk-downloader/src/download/extracted_files.rs @@ -80,17 +80,17 @@ impl ExtractedFiles { } /// * `path` - must be a relative path without `.`, `..`, `/`, `prefix:/` - /// and must not be empty, for these values it is guaranteed to - /// return `None`. - /// But could be set to "." for top-level. + /// and must not be empty, for these values it is guaranteed to + /// return `None`. + /// But could be set to "." for top-level. pub fn get_entry(&self, path: &Path) -> Option<&ExtractedFilesEntry> { self.0.get(path) } /// * `path` - must be a relative path without `.`, `..`, `/`, `prefix:/` - /// and must not be empty, for these values it is guaranteed to - /// return `None`. - /// But could be set to "." for top-level. + /// and must not be empty, for these values it is guaranteed to + /// return `None`. + /// But could be set to "." for top-level. pub fn get_dir(&self, path: &Path) -> Option<&HashSet>> { match self.get_entry(path)? { ExtractedFilesEntry::Dir(file_names) => Some(file_names), @@ -99,9 +99,9 @@ impl ExtractedFiles { } /// * `path` - must be a relative path without `.`, `..`, `/`, `prefix:/` - /// and must not be empty, for these values it is guaranteed to - /// return `false`. - /// But could be set to "." for top-level. + /// and must not be empty, for these values it is guaranteed to + /// return `false`. + /// But could be set to "." for top-level. pub fn has_file(&self, path: &Path) -> bool { matches!(self.get_entry(path), Some(ExtractedFilesEntry::File)) } diff --git a/crates/binstalk-downloader/src/remote.rs b/crates/binstalk-downloader/src/remote.rs index 66fd365c..1ab1391c 100644 --- a/crates/binstalk-downloader/src/remote.rs +++ b/crates/binstalk-downloader/src/remote.rs @@ -390,7 +390,7 @@ fn parse_header_retry_after(headers: &HeaderMap) -> Option { let header = headers .get_all(RETRY_AFTER) .into_iter() - .last()? + .next_back()? .to_str() .ok()?; diff --git a/crates/binstalk-manifests/src/cargo_config.rs b/crates/binstalk-manifests/src/cargo_config.rs index dc9985dc..22e25971 100644 --- a/crates/binstalk-manifests/src/cargo_config.rs +++ b/crates/binstalk-manifests/src/cargo_config.rs @@ -86,9 +86,9 @@ impl Config { } /// * `dir` - path to the dir where the config.toml is located. - /// For relative path in the config, `Config::load_from_reader` - /// will join the `dir` and the relative path to form the final - /// path. + /// For relative path in the config, `Config::load_from_reader` + /// will join the `dir` and the relative path to form the final + /// path. pub fn load_from_reader( mut reader: R, dir: &Path,