From 98aed71ef5ab3c0b1415e826abfd2a7826bef0ad Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 21 Feb 2024 14:28:16 +0100 Subject: [PATCH] clean with pedantic clippy --- Cargo.lock | 1 + src/law.rs | 18 +++++++++--------- src/part.rs | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a37cae6..da7d631 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -527,6 +527,7 @@ dependencies = [ [[package]] name = "risp" version = "0.1.0" +source = "git+https://git.hofer.link/philipp/risp.git#ad8d5d828e508bd2186e3b6a8ad6f92c6e1baf67" dependencies = [ "clap", "directories", diff --git a/src/law.rs b/src/law.rs index 26e35b3..10e75c1 100644 --- a/src/law.rs +++ b/src/law.rs @@ -39,10 +39,10 @@ fn print_paragraph(section: Section) -> String { ret.push_str("
"); ret.push_str(&format!("{}", section.symb)); if let Some(par_header) = section.par_header { - ret.push_str(&format!("{}", par_header)); + ret.push_str(&format!("{par_header}")); } if let Some(note) = section.par_note { - ret.push_str(&format!("Beachte: {}", note)); + ret.push_str(&format!("Beachte: {note}")); } ret.push_str(&print_content(section.content)); @@ -54,7 +54,7 @@ fn print_header(header: Heading, level: usize) -> String { let mut ret = String::new(); let mut header_title = header.name.clone(); if let Some(desc) = header.desc { - header_title.push_str(&format!(" ({desc})")) + header_title.push_str(&format!(" ({desc})")); } ret.push_str(&format!( @@ -96,15 +96,15 @@ fn get_content(config_path: &str) -> (String, String) { pub(crate) fn create_law_files() -> String { let mut configs: Vec<_> = fs::read_dir("./laws") .unwrap() - .map(|r| r.unwrap()) + .map(std::result::Result::unwrap) .collect(); - configs.sort_by_key(|dir| dir.path()); // Order by name - // + configs.sort_by_key(std::fs::DirEntry::path); // Order by name + let mut li_of_files = String::new(); for config in configs { let filename = config.file_name().into_string().unwrap(); //TODO: use proper logic... - let law_name = filename.replace(".toml", ""); + let law_filename = filename.replace(".toml", ""); let path = format!("{}", config.path().display()); let (lawname, content) = get_content(&path); @@ -117,9 +117,9 @@ pub(crate) fn create_law_files() -> String { let site = Parts::new().perform(site); li_of_files.push_str(&format!( - "
  • {lawname}
  • " + "
  • {lawname}
  • " )); - fs::write(&format!("output/{law_name}.html"), &site).expect("Unable to write file"); + fs::write(&format!("output/{law_filename}.html"), &site).expect("Unable to write file"); } li_of_files diff --git a/src/part.rs b/src/part.rs index 3770570..a7e01af 100644 --- a/src/part.rs +++ b/src/part.rs @@ -24,7 +24,7 @@ impl Parts { pub(crate) fn perform(&self, input: String) -> String { let mut input = input; for (key, value) in &self.parts { - let replace = format!("{{{{{}}}}}", key); + let replace = format!("{{{{{key}}}}}"); input = input.replace(&replace, value); } input