This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

🔥 Remove useless crate num-traits

+22 -31
-1
Cargo.lock
··· 4595 4595 "nanoid", 4596 4596 "ndarray", 4597 4597 "nih_plug", 4598 - "num-traits", 4599 4598 "once_cell", 4600 4599 "quick-xml", 4601 4600 "rand 0.9.2",
-1
Cargo.toml
··· 109 109 quick-xml = "0.38.3" 110 110 vgv = { git = "https://github.com/gwennlbh/vgvf", version = "0.1.0", optional = true} 111 111 serde-aux = "4.7.0" 112 - num-traits = "0.2.19" 113 112 114 113 115 114 [dev-dependencies]
+22 -29
src/ui.rs
··· 2 2 use console::Style; 3 3 use indicatif::{ProgressBar, ProgressStyle}; 4 4 use itertools::Itertools; 5 - use num_traits::ops::euclid::Euclid; 6 5 use std::borrow::Cow; 7 6 use std::collections::HashMap; 8 7 use std::ops::Range; ··· 136 135 .join(", ") 137 136 } 138 137 139 - pub(crate) fn format_timestamp(duration: impl IntoTimestamp) -> String { 140 - format!( 141 - "{}", 142 - DateTime::from_timestamp_millis(duration.as_millis() as i64) 143 - .unwrap() 144 - .format("%H:%M:%S%.3f") 145 - ) 146 - } 147 - 148 138 pub(crate) fn format_duration(duration: Duration) -> String { 149 - let (hours, rest) = duration.as_millis().div_rem_euclid(&3_600_000); 150 - let (minutes, rest) = rest.div_rem_euclid(&60_000); 151 - let (seconds, milliseconds) = rest.div_rem_euclid(&1_000); 139 + let (hours, rest) = duration.as_millis().div_rem(&3_600_000); 140 + let (minutes, rest) = rest.div_rem(&60_000); 141 + let (seconds, milliseconds) = rest.div_rem(&1_000); 152 142 153 143 if hours > 0 { 154 144 format!("{} h {:02} m {:02} s", hours, minutes, seconds) ··· 161 151 } 162 152 } 163 153 154 + trait DivRem<T> { 155 + fn div_rem(&self, rhs: &T) -> (T, T); 156 + } 157 + 158 + impl DivRem<u128> for u128 { 159 + fn div_rem(&self, rhs: &u128) -> (u128, u128) { 160 + (self / rhs, self % rhs) 161 + } 162 + } 163 + 164 + pub(crate) fn format_timestamp(ms: usize) -> String { 165 + format!( 166 + "{}", 167 + DateTime::from_timestamp_millis(ms as i64) 168 + .unwrap() 169 + .format("%H:%M:%S%.3f") 170 + ) 171 + } 172 + 164 173 pub(crate) fn format_timestamp_range(ms_range: &Range<usize>) -> String { 165 174 format!( 166 175 "from {} to {}", ··· 176 185 path.to_string_lossy() 177 186 ) 178 187 } 179 - 180 - pub(crate) trait IntoTimestamp { 181 - fn as_millis(&self) -> usize; 182 - } 183 - 184 - impl IntoTimestamp for usize { 185 - fn as_millis(&self) -> usize { 186 - *self 187 - } 188 - } 189 - 190 - // impl IntoTimestamp for std::time::Duration { 191 - // fn as_millis(&self) -> usize { 192 - // self.as_millis() as usize 193 - // } 194 - // }