# HG changeset patch # User Raphaël Gomès # Date 1668436985 -3600 # Node ID 4d729a98673d135602182cddc9ed5a0984f09c8e # Parent ec399ddf6764c13303ae3f706b68fce7d7ae61b9 hg-core: make use of `strip_suffix` now that we're using Rust 1.45+ diff -r ec399ddf6764 -r 4d729a98673d rust/hg-core/src/config/values.rs --- 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 {