From fe7d2dbcebd4939a3809dee5128814b7f1c98671 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Wed, 8 Apr 2026 01:54:43 +0200 Subject: [PATCH] fix(ug-parser): address clippy warnings in parser --- crates/infrastructure/ug-parser/src/parser.rs | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/crates/infrastructure/ug-parser/src/parser.rs b/crates/infrastructure/ug-parser/src/parser.rs index 8f0c2d9..f3cb898 100644 --- a/crates/infrastructure/ug-parser/src/parser.rs +++ b/crates/infrastructure/ug-parser/src/parser.rs @@ -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(); } } _ => {}