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