diff --git a/src/law/mod.rs b/src/law/mod.rs index 6d740a3..ed00e41 100644 --- a/src/law/mod.rs +++ b/src/law/mod.rs @@ -58,7 +58,7 @@ impl From for Law { name: header.borrow().name.clone(), desc: header.borrow().desc.clone(), content: header.borrow().clone().into(), - }) + }); } Self { @@ -100,7 +100,7 @@ impl From for HeadingContent { name: child.borrow().name.clone(), desc: child.borrow().desc.clone(), content: child.borrow().clone().into(), - }) + }); } Self::Heading(ret) @@ -173,18 +173,18 @@ impl LawBuilder { let mut law_id = None; if name == "UrhG" { - law_id = Some(10001848); + law_id = Some(10_001_848); classifiers.push(Classifier::new("Hauptstück", Arc::new(&contains)).root()); classifiers.push(Classifier::new("Abschnitt", Arc::new(&contains))); classifiers.push(Classifier::new("Number", Arc::new(&starts_with_number))); } else if name == "MSchG" { - law_id = Some(10002180); + law_id = Some(10_002_180); classifiers.push(Classifier::new("Abschnitt", Arc::new(&contains)).root()); classifiers.push(Classifier::new("Number", Arc::new(&starts_with_number))); } else if name == "ABGB" { - law_id = Some(10001622); + law_id = Some(10_001_622); classifiers.push(Classifier::new("Einleitung", Arc::new(&contains)).root()); classifiers.push(Classifier::new("Theil", Arc::new(&contains)).root()); @@ -198,7 +198,7 @@ impl LawBuilder { classifiers.push(Classifier::new("num", Arc::new(&starts_with_number))); classifiers.push(Classifier::new("rom", Arc::new(&starts_with_roman_number))); } else if name == "FSG" { - law_id = Some(10003898); + law_id = Some(10_003_898); classifiers.push(Classifier::new("Artikel", Arc::new(&contains)).root()); @@ -215,16 +215,16 @@ impl LawBuilder { )); classifiers.push(Classifier::new("num", Arc::new(&starts_with_number))); } else if name == "VVG" { - law_id = Some(20004425); + law_id = Some(20_004_425); classifiers.push(Classifier::new("Abschnitt", Arc::new(&contains)).root()); } else if name == "KSchG" { - law_id = Some(10002462); + law_id = Some(10_002_462); classifiers.push(Classifier::new("Hauptstück", Arc::new(&contains)).root()); classifiers.push(Classifier::new("Abschnitt", Arc::new(&contains))); } else if name == "StGB" { - law_id = Some(10002296); + law_id = Some(10_002_296); classifiers.push(Classifier::new("Teil", Arc::new(&contains)).root()); classifiers.push(Classifier::new("Abschnitt", Arc::new(&contains))); @@ -249,7 +249,7 @@ impl LawBuilder { } } - builder.into() + builder } fn responsible_classifier(&self, name: &str) -> Option<&Classifier> { @@ -358,7 +358,7 @@ impl LawBuilder { symb: par, par_header, content, - }) + }); } /// Next paragraph has a header, store its name. @@ -447,7 +447,7 @@ impl std::fmt::Debug for ClassifierInstance { .field("desc", &self.desc) .field("sections", &self.sections) .field("children", &self.children) - .finish() + .finish_non_exhaustive() } } @@ -500,7 +500,7 @@ impl std::fmt::Debug for Classifier { .field("name", &self.name) .field("instances", &self.instances) .field("child", &self.child) - .finish() + .finish_non_exhaustive() } } @@ -515,14 +515,7 @@ impl Display for Content { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Text(a) => f.write_str(&format!("{a}\n")), - Self::Item(a) => { - let mut ret = String::new(); - for aa in a { - ret.push_str(&format!("{aa}")); - } - f.write_str(&ret) - } - Self::List(a) => { + Self::Item(a) | Self::List(a) => { let mut ret = String::new(); for aa in a { ret.push_str(&format!("{aa}")); diff --git a/src/par/mod.rs b/src/par/mod.rs index 5030d6b..fce2fb5 100644 --- a/src/par/mod.rs +++ b/src/par/mod.rs @@ -39,7 +39,7 @@ pub(crate) fn parse_from_str(xml: &str, builder: &mut LawBuilder) -> ResultErster Abschnitt"#, ); // StGB - let xml = xml.replace(r#""#, r#""#); // StGB... + let xml = xml.replace(r#""#, r""); // StGB... let xml = xml.replace( r#"Strafbare Handlungen gegen Leib und Leben"#, @@ -113,14 +113,14 @@ pub(crate) fn parse_from_str(xml: &str, builder: &mut LawBuilder) -> Result", ""); let xml = xml.replace( - r#"(Anm.: § 69 aufgehoben durch Art. 1 Z 12, BGBl. I Nr. 124/2017)"#, - r#"§ 69.(Anm.: § 69 aufgehoben durch Art. 1 Z 12, BGBl. I Nr. 124/2017)"#, + r"(Anm.: § 69 aufgehoben durch Art. 1 Z 12, BGBl. I Nr. 124/2017)", + r"§ 69.(Anm.: § 69 aufgehoben durch Art. 1 Z 12, BGBl. I Nr. 124/2017)", ); // § 49d FSG let xml = xml.replace( r#"Die Finanzordnungswidrigkeit wird mit einer Geldstrafe bis zu 50 000 Euro geahndet."#, - r#"Die Finanzordnungswidrigkeit wird mit einer Geldstrafe bis zu 50 000 Euro geahndet."#, + r"Die Finanzordnungswidrigkeit wird mit einer Geldstrafe bis zu 50 000 Euro geahndet.", ); // § 127 FSG diff --git a/src/par/parser.rs b/src/par/parser.rs index 60e9897..cfe36b3 100644 --- a/src/par/parser.rs +++ b/src/par/parser.rs @@ -118,8 +118,6 @@ impl Abschnitt { } } - // TODO: Continue here: We want to create a `Section`. - // // We have 2 tasks // 1) Get paragraph id // 2) Get content @@ -149,7 +147,7 @@ impl Abschnitt { Content::Text(absatz.content.replace('\u{a0}', " ")), Content::List(table.get_list()), Content::Text(after_absatz.content), - ])) + ])); } else { absatze.push(Content::List(vec![ Content::Text(absatz.content.replace('\u{a0}', " ")), @@ -441,8 +439,8 @@ impl AbsatzAbs { let gldsym = match c.peek() { Some(child) => { - if Leaf::test(child, "gldsym".into()) { - Some(Leaf::parse(c.next().unwrap(), "gldsym".into()).replace('\u{a0}', " ")) + if Leaf::test(child, "gldsym") { + Some(Leaf::parse(c.next().unwrap(), "gldsym").replace('\u{a0}', " ")) } else { None } @@ -466,10 +464,10 @@ pub(crate) struct Leaf { content: String, } impl Leaf { - pub(crate) fn test(n: &Node, name: String) -> bool { + pub(crate) fn test(n: &Node, name: &str) -> bool { n.tag_name().name() == name && n.children().count() == 1 } - pub(crate) fn parse(n: Node, name: String) -> String { + pub(crate) fn parse(n: Node, name: &str) -> String { assert!(n.tag_name().name() == name); assert_eq!(n.children().count(), 1); @@ -498,7 +496,9 @@ impl Absatz { content: text.into(), } } else { - Self { content: "".into() } + Self { + content: String::new(), + } } } } diff --git a/src/risparser/overview.rs b/src/risparser/overview.rs index 621faee..d5da3fe 100644 --- a/src/risparser/overview.rs +++ b/src/risparser/overview.rs @@ -77,9 +77,9 @@ fn fetch_page(overview_id: usize, page: usize) -> Result { ureq::post("https://data.bka.gv.at/ris/api/v2.6/Bundesrecht") .send_form(&[ ("Applikation", "BrKons"), - ("Gesetzesnummer", &format!("{}", overview_id)), + ("Gesetzesnummer", &format!("{overview_id}")), ("DokumenteProSeite", "OneHundred"), - ("Seitennummer", &format!("{}", page)), + ("Seitennummer", &format!("{page}")), ("Fassung.FassungVom", ¤t_date()), ])? .into_string()?,