From c19921b9a3052c2fe58529c54f7f22e5f6b3ba62 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sun, 09 Jul 2023 19:08:03 +0100 Subject: [PATCH] Fix clippy build --- src/git.rs | 16 +++++++--------- src/main.rs | 4 ++-- src/database/indexer.rs | 4 ++-- src/methods/filters.rs | 2 +- src/database/schema/commit.rs | 2 +- src/database/schema/tag.rs | 2 +- src/methods/repo/mod.rs | 2 +- src/methods/repo/tree.rs | 4 ++-- 8 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/git.rs b/src/git.rs index f1414c4..08bc24d 100644 --- a/src/git.rs +++ a/src/git.rs @@ -225,25 +225,19 @@ .context("Couldn't get the tree that the HEAD refers to")?; for name in README_FILES { - let tree_entry = if let Some(file) = tree.get_name(name) { - file - } else { + let Some(tree_entry) = tree.get_name(name) else { continue; }; - let blob = if let Some(blob) = tree_entry + let Some(blob) = tree_entry .to_object(&repo) .ok() .and_then(|v| v.into_blob().ok()) - { - blob - } else { + else { continue; }; - let content = if let Ok(content) = std::str::from_utf8(blob.content()) { - content - } else { + let Ok(content) = std::str::from_utf8(blob.content()) else { continue; }; @@ -508,7 +502,7 @@ let email = diff .format_email(1, 1, commit, None) .context("Couldn't build diff for commit")?; - diff_plain.extend_from_slice(&*email); + diff_plain.extend_from_slice(&email); let diff_stats = diff .stats()? diff --git a/src/main.rs b/src/main.rs index bd0d3d7..92c6a4b 100644 --- a/src/main.rs +++ a/src/main.rs @@ -79,7 +79,7 @@ let theme = bat_assets.get_theme("GitHub"); let css = syntect::html::css_for_theme_with_class_style(theme, ClassStyle::Spaced).unwrap(); let css = Box::leak( - format!(r#"@media (prefers-color-scheme: light){{{}}}"#, css) + format!(r#"@media (prefers-color-scheme: light){{{css}}}"#) .into_boxed_str() .into_boxed_bytes(), ); @@ -88,7 +88,7 @@ let dark_css = syntect::html::css_for_theme_with_class_style(dark_theme, ClassStyle::Spaced).unwrap(); let dark_css = Box::leak( - format!(r#"@media (prefers-color-scheme: dark){{{}}}"#, dark_css) + format!(r#"@media (prefers-color-scheme: dark){{{dark_css}}}"#) .into_boxed_str() .into_boxed_bytes(), ); diff --git a/src/database/indexer.rs b/src/database/indexer.rs index 5636c0b..8ea240f 100644 --- a/src/database/indexer.rs +++ a/src/database/indexer.rs @@ -44,7 +44,7 @@ let description = std::fs::read(repository.join("description")).unwrap_or_default(); let description = Some(String::from_utf8_lossy(&description)).filter(|v| !v.is_empty()); - let git_repository = git2::Repository::open(scan_path.join(&relative)).unwrap(); + let git_repository = git2::Repository::open(scan_path.join(relative)).unwrap(); Repository { id, @@ -131,7 +131,7 @@ // a complete and utter hack to remove potentially dropped commits from our tree, // we'll need to add `clear()` to sled's tx api to remove this for to_remove in (i + 1)..(i + 100) { - commit_tree.remove(&to_remove.to_be_bytes()).unwrap(); + commit_tree.remove(to_remove.to_be_bytes()).unwrap(); } } } diff --git a/src/methods/filters.rs b/src/methods/filters.rs index fd79efe..f6d6f6b 100644 --- a/src/methods/filters.rs +++ a/src/methods/filters.rs @@ -17,7 +17,7 @@ } pub fn md5(s: &str) -> Result { - Ok(hex::encode(&md5::compute(s).0)) + Ok(hex::encode(md5::compute(s).0)) } #[allow(dead_code)] diff --git a/src/database/schema/commit.rs b/src/database/schema/commit.rs index 0495360..a608155 100644 --- a/src/database/schema/commit.rs +++ a/src/database/schema/commit.rs @@ -40,7 +40,7 @@ pub fn insert(&self, batch: &CommitTree, id: usize) { batch - .insert(&id.to_be_bytes(), bincode::serialize(self).unwrap()) + .insert(id.to_be_bytes(), bincode::serialize(self).unwrap()) .unwrap(); } } diff --git a/src/database/schema/tag.rs b/src/database/schema/tag.rs index 942ee5d..0301405 100644 --- a/src/database/schema/tag.rs +++ a/src/database/schema/tag.rs @@ -22,7 +22,7 @@ pub fn insert(&self, batch: &TagTree, name: &str) { batch - .insert(&name.as_bytes(), bincode::serialize(self).unwrap()) + .insert(name.as_bytes(), bincode::serialize(self).unwrap()) .unwrap(); } } diff --git a/src/methods/repo/mod.rs b/src/methods/repo/mod.rs index c6bbfbe..9a9829e 100644 --- a/src/methods/repo/mod.rs +++ a/src/methods/repo/mod.rs @@ -162,7 +162,7 @@ impl From> for Error { fn from(e: Arc) -> Self { - Self(anyhow::Error::msg(format!("{:?}", e))) + Self(anyhow::Error::msg(format!("{e:?}"))) } } diff --git a/src/methods/repo/tree.rs b/src/methods/repo/tree.rs index e20434d..0101353 100644 --- a/src/methods/repo/tree.rs +++ a/src/methods/repo/tree.rs @@ -29,12 +29,12 @@ let mut prefix = "?"; if let Some(id) = self.id.as_deref() { - write!(f, "{}id={}", prefix, id)?; + write!(f, "{prefix}id={id}")?; prefix = "&"; } if let Some(branch) = self.branch.as_deref() { - write!(f, "{}h={}", prefix, branch)?; + write!(f, "{prefix}h={branch}")?; } Ok(()) -- rgit 0.1.3