fix(ug-parser): address clippy warnings in parser

This commit is contained in:
2026-04-08 01:54:43 +02:00
parent 776389af49
commit fe7d2dbceb

View File

@@ -110,13 +110,13 @@ impl UgHtmlParser {
// Blank line — flush pending chords if any (chord line with no following lyric)
if trimmed.is_empty() {
if !pending_chords.is_empty() {
if let Some(sec) = current_section.as_mut() {
sec.lines.push(LyricLine {
text: String::new(),
chords: pending_chords.drain(..).collect(),
});
}
if !pending_chords.is_empty()
&& let Some(sec) = current_section.as_mut()
{
sec.lines.push(LyricLine {
text: String::new(),
chords: std::mem::take(&mut pending_chords),
});
}
continue;
}
@@ -131,7 +131,7 @@ impl UgHtmlParser {
if let Some(sec) = current_section.as_mut() {
sec.lines.push(LyricLine {
text: trimmed.to_string(),
chords: pending_chords.drain(..).collect(),
chords: std::mem::take(&mut pending_chords),
});
}
}
@@ -174,13 +174,12 @@ impl UgHtmlParser {
offset += text.chars().count();
}
Node::Element(el) => {
if el.name() == "span" {
if let Some(chord_name) = el.attr("data-name") {
if let Some(chord) = Chord::parse(chord_name) {
chords.push(ChordPosition { offset, chord });
offset += chord_name.chars().count();
}
}
if el.name() == "span"
&& let Some(chord_name) = el.attr("data-name")
&& let Some(chord) = Chord::parse(chord_name)
{
chords.push(ChordPosition { offset, chord });
offset += chord_name.chars().count();
}
}
_ => {}