Show More
@@ -30,10 +30,8 b' pub(super) fn parse_byte_size(value: &[u' | |||||
30 | ("b", 1 << 0), // Needs to be last |
|
30 | ("b", 1 << 0), // Needs to be last | |
31 | ]; |
|
31 | ]; | |
32 | for &(unit, multiplier) in UNITS { |
|
32 | for &(unit, multiplier) in UNITS { | |
33 | // TODO: use `value.strip_suffix(unit)` when we require Rust 1.45+ |
|
33 | if let Some(value) = value.strip_suffix(unit) { | |
34 | if value.ends_with(unit) { |
|
34 | let float: f64 = value.trim().parse().ok()?; | |
35 | let value_before_unit = &value[..value.len() - unit.len()]; |
|
|||
36 | let float: f64 = value_before_unit.trim().parse().ok()?; |
|
|||
37 | if float >= 0.0 { |
|
35 | if float >= 0.0 { | |
38 | return Some((float * multiplier as f64).round() as u64); |
|
36 | return Some((float * multiplier as f64).round() as u64); | |
39 | } else { |
|
37 | } else { |
General Comments 0
You need to be logged in to leave comments.
Login now