From 98aed71ef5ab3c0b1415e826abfd2a7826bef0ad Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 21 Feb 2024 14:28:16 +0100 Subject: [PATCH 1/2] 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 From c415667263386faceadb8246e2ec370803846aff Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 21 Feb 2024 14:28:31 +0100 Subject: [PATCH 2/2] update deps --- Cargo.lock | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da7d631..f7cac10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,12 +97,9 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" [[package]] name = "cfg-if"