]> git.seodisparate.com - mpd_info_screen/commitdiff
Refactor time_to_percentage(...)
authorStephen Seo <seo.disparate@gmail.com>
Mon, 24 Jun 2024 05:26:15 +0000 (14:26 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 24 Jun 2024 05:27:44 +0000 (14:27 +0900)
src/display.rs

index 09db0434c475008f16b1a7cb773e36a897ee17b2..d52086af346875fae42c8eb68529d461bc416154 100644 (file)
@@ -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"))]