--- a/rust/hg-core/src/config/values.rs Mon Nov 14 15:34:51 2022 +0100
+++ b/rust/hg-core/src/config/values.rs Mon Nov 14 15:43:05 2022 +0100
@@ -30,10 +30,8 @@
("b", 1 << 0), // Needs to be last
];
for &(unit, multiplier) in UNITS {
- // TODO: use `value.strip_suffix(unit)` when we require Rust 1.45+
- if value.ends_with(unit) {
- let value_before_unit = &value[..value.len() - unit.len()];
- let float: f64 = value_before_unit.trim().parse().ok()?;
+ if let Some(value) = value.strip_suffix(unit) {
+ let float: f64 = value.trim().parse().ok()?;
if float >= 0.0 {
return Some((float * multiplier as f64).round() as u64);
} else {