clean with pedantic clippy
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run

This commit is contained in:
2024-02-21 14:21:22 +01:00
parent 287d7bdb8b
commit cc6bedfdf1
6 changed files with 53 additions and 58 deletions

View File

@@ -62,7 +62,7 @@ impl Absatz {
{
// After a 'absatz' there can be a '<absatz typ="[satz|erltext]"' which should be part of the first absatz
// (e.g. 1209 ABGB)
content.push(Content::Text(Absatz::parse(c.next().unwrap()).content))
content.push(Content::Text(Absatz::parse(c.next().unwrap()).content));
} else {
break;
}

View File

@@ -41,7 +41,7 @@ impl Abschnitt {
ret.handle_metadata(&mut c, builder);
if !ret.handle_headers(&mut c, builder) {
if !Self::handle_headers(&mut c, builder) {
return ret;
}
@@ -49,9 +49,8 @@ impl Abschnitt {
// Special handling of first paragraph (needs id)...
let (par_id, first_abs) = Absatz::parse_full(&mut c);
let par_id = match par_id {
Some(par_id) => par_id,
None => panic!("First paragraph needs to have an id, not found"),
let Some(par_id) = par_id else {
panic!("First paragraph needs to have an id, not found")
};
absatze.push(first_abs);
@@ -118,9 +117,10 @@ impl Abschnitt {
}
}
value = value.trim().into();
if value.is_empty() {
panic!("Expected at least on erltext-absatz after title meta-data");
}
assert!(
!value.is_empty(),
"Expected at least on erltext-absatz after title meta-data"
);
// We want ot use this information in our markdown output.
// TODO: Use all metadata, instead of this specific call
@@ -146,7 +146,7 @@ impl Abschnitt {
// we have optionally headers. Such as "Einleitung", "Von den bürgerlichen Gesetzen üerhaupt,"
// etc. If we have headers which indicate that we are done and we want to stop parsing
// ("anlage" + "Artikel" we indicate this wish by returning false.
fn handle_headers(&self, c: &mut Peekable<Children>, builder: &mut LawBuilder) -> bool {
fn handle_headers(c: &mut Peekable<Children>, builder: &mut LawBuilder) -> bool {
while let Some(child) = c.peek() {
// Schiffahrtsgesetz: stop @ anlagen (for now)
if Ueberschrift::test(child, "anlage") {

View File

@@ -43,14 +43,13 @@ impl<'a> From<&'a Node<'a, 'a>> for Expect<'a> {
impl<'a> Expect<'a> {
fn tag(&self, value: &str) {
if self.node.tag_name().name() != value {
panic!(
"Expected tag '{value}', got {} (tag: {}, content: {:?})",
self.node.tag_name().name(),
self.node.tag_name().name(),
self.node.text(),
);
}
assert!(
!(self.node.tag_name().name() != value),
"Expected tag '{value}', got {} (tag: {}, content: {:?})",
self.node.tag_name().name(),
self.node.tag_name().name(),
self.node.text(),
);
}
}