diff --git a/src/database/indexer.rs b/src/database/indexer.rs
@@ -44,7 +44,7 @@ fn update_repository_metadata(scan_path: &Path, db: &sled::Db) {
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 @@ fn update_repository_reflog(scan_path: &Path, db: &sled::Db) {
// 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/database/schema/commit.rs b/src/database/schema/commit.rs
@@ -40,7 +40,7 @@ impl<'a> Commit<'a> {
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
@@ -22,7 +22,7 @@ impl<'a> Tag<'a> {
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/git.rs b/src/git.rs
@@ -225,25 +225,19 @@ impl OpenRepository {
.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 @@ fn fetch_diff_and_stats(
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
@@ -79,7 +79,7 @@ async fn main() {
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 @@ async fn main() {
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/methods/filters.rs b/src/methods/filters.rs
@@ -17,7 +17,7 @@ pub fn hex(s: &[u8]) -> Result<String, askama::Error> {
}
pub fn md5(s: &str) -> Result<String, askama::Error> {
- Ok(hex::encode(&md5::compute(s).0))
+ Ok(hex::encode(md5::compute(s).0))
}
#[allow(dead_code)]
diff --git a/src/methods/repo/mod.rs b/src/methods/repo/mod.rs
@@ -162,7 +162,7 @@ pub struct Error(anyhow::Error);
impl From<Arc<anyhow::Error>> for Error {
fn from(e: Arc<anyhow::Error>) -> 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
@@ -29,12 +29,12 @@ impl Display for UriQuery {
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(())