changeset 49753:4d729a98673d

hg-core: make use of `strip_suffix` now that we're using Rust 1.45+
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 14 Nov 2022 15:43:05 +0100
parents ec399ddf6764
children a5447a4a8c5d
files rust/hg-core/src/config/values.rs
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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 {