fix(ug-parser): address clippy warnings in parser
This commit is contained in:
@@ -110,13 +110,13 @@ 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 {
|
{
|
||||||
text: String::new(),
|
sec.lines.push(LyricLine {
|
||||||
chords: pending_chords.drain(..).collect(),
|
text: String::new(),
|
||||||
});
|
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,13 +174,12 @@ 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 });
|
{
|
||||||
offset += chord_name.chars().count();
|
chords.push(ChordPosition { offset, chord });
|
||||||
}
|
offset += chord_name.chars().count();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|||||||
Reference in New Issue
Block a user