From: Stephen Seo Date: Mon, 24 Jun 2024 05:26:15 +0000 (+0900) Subject: Refactor time_to_percentage(...) X-Git-Tag: 0.4.13~2 X-Git-Url: https://git.seodisparate.com/stephenseo/static/git-logo.png?a=commitdiff_plain;h=8ebeac0499cfcb319a8dacd603f8282f78d45a7f;p=mpd_info_screen Refactor time_to_percentage(...) --- diff --git a/src/display.rs b/src/display.rs index 09db043..d52086a 100644 --- a/src/display.rs +++ b/src/display.rs @@ -55,11 +55,7 @@ fn seconds_to_time(seconds: f64) -> String { } fn time_to_percentage(total: f64, current: f64) -> String { - let result = (100.0f64 * current / total).round().to_string(); - match result.split_once('.') { - Some((a, _)) => a.to_string() + "%", - None => result + "%", - } + ((100.0f64 * current / total).round() as i32).to_string() + "%" } #[cfg(not(feature = "unicode_support"))]