Skip to content

Commit c3a74f8

Browse files
committed
apply clippy suggestion and remove debug prints
1 parent 8865069 commit c3a74f8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/formatter.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use regex::Regex;
2+
use std::cmp::Ordering;
23

34
/// Handles track formatting.
45
pub struct TrackFormatter {
@@ -163,21 +164,19 @@ impl TrackFormatter {
163164
}
164165

165166
/// Check parenthesis counts match and insert missing.
166-
fn balance_parenthesis(&self, mut title: String) -> String {
167+
fn balance_parenthesis(&self, title: String) -> String {
167168
let open_count = title.matches('(').count();
168169
let close_count = title.matches(')').count();
169-
if open_count > close_count {
170-
title = Self::add_missing_closing_parentheses(&title);
171-
} else if open_count < close_count {
172-
title = Self::add_missing_opening_parentheses(&title);
170+
match open_count.cmp(&close_count) {
171+
Ordering::Greater => Self::add_missing_closing_parentheses(&title),
172+
Ordering::Less => Self::add_missing_opening_parentheses(&title),
173+
_ => title,
173174
}
174-
title
175175
}
176176

177177
fn add_missing_closing_parentheses(text: &str) -> String {
178178
let mut open_count: usize = 0;
179179
let mut result = String::new();
180-
println!("Missing closing");
181180

182181
for char in text.chars() {
183182
match char {
@@ -207,7 +206,6 @@ impl TrackFormatter {
207206
fn add_missing_opening_parentheses(text: &str) -> String {
208207
let mut open_count: usize = 0;
209208
let mut result = String::new();
210-
println!("Missing opening");
211209

212210
for char in text.chars().rev() {
213211
match char {

0 commit comments

Comments
 (0)