Some clippy cleanup

This commit is contained in:
Eric Huss 2025-02-20 10:23:47 -08:00
parent e7b69114ed
commit fbc21592af

View file

@ -54,10 +54,10 @@ impl StaticFiles {
} }
this.add_builtin("css/variables.css", &theme.variables_css); this.add_builtin("css/variables.css", &theme.variables_css);
if let Some(contents) = &theme.favicon_png { if let Some(contents) = &theme.favicon_png {
this.add_builtin("favicon.png", &contents); this.add_builtin("favicon.png", contents);
} }
if let Some(contents) = &theme.favicon_svg { if let Some(contents) = &theme.favicon_svg {
this.add_builtin("favicon.svg", &contents); this.add_builtin("favicon.svg", contents);
} }
this.add_builtin("highlight.css", &theme.highlight_css); this.add_builtin("highlight.css", &theme.highlight_css);
this.add_builtin("tomorrow-night.css", &theme.tomorrow_night_css); this.add_builtin("tomorrow-night.css", &theme.tomorrow_night_css);
@ -131,8 +131,8 @@ impl StaticFiles {
.iter() .iter()
.chain(html_config.additional_js.iter()); .chain(html_config.additional_js.iter());
for custom_file in custom_files.cloned() { for custom_file in custom_files {
let input_location = root.join(&custom_file); let input_location = root.join(custom_file);
this.static_files.push(StaticFile::Additional { this.static_files.push(StaticFile::Additional {
input_location, input_location,
@ -245,8 +245,8 @@ impl StaticFiles {
.expect("capture 1 in resource regex") .expect("capture 1 in resource regex")
.as_bytes(); .as_bytes();
let name = std::str::from_utf8(name).expect("resource name with invalid utf8"); let name = std::str::from_utf8(name).expect("resource name with invalid utf8");
let resource_filename = hash_map.get(name).map(|s| &s[..]).unwrap_or(&name); let resource_filename = hash_map.get(name).map(|s| &s[..]).unwrap_or(name);
let path_to_root = utils::fs::path_to_root(&filename); let path_to_root = utils::fs::path_to_root(filename);
format!("{}{}", path_to_root, resource_filename) format!("{}{}", path_to_root, resource_filename)
.as_bytes() .as_bytes()
.to_owned() .to_owned()
@ -261,7 +261,7 @@ impl StaticFiles {
} else { } else {
Cow::Borrowed(&data[..]) Cow::Borrowed(&data[..])
}; };
write_file(destination, &filename, &data)?; write_file(destination, filename, &data)?;
} }
StaticFile::Additional { StaticFile::Additional {
ref input_location, ref input_location,
@ -284,7 +284,7 @@ impl StaticFiles {
let data = replace_all(&self.hash_map, &data, filename); let data = replace_all(&self.hash_map, &data, filename);
write_file(destination, filename, &data)?; write_file(destination, filename, &data)?;
} else { } else {
fs::copy(&input_location, &output_location).with_context(|| { fs::copy(input_location, &output_location).with_context(|| {
format!( format!(
"Unable to copy {} to {}", "Unable to copy {} to {}",
input_location.display(), input_location.display(),