From a3895bba595149922bd7aaef9783f0f7bd9d9513 Mon Sep 17 00:00:00 2001 From: Sebastian Holgersson Date: Sun, 2 Jan 2022 02:16:59 +0100 Subject: [PATCH] numfmt: replace if let with simpler match --- src/uu/numfmt/src/format.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/uu/numfmt/src/format.rs b/src/uu/numfmt/src/format.rs index 42f7d45bf..f66e1ac0a 100644 --- a/src/uu/numfmt/src/format.rs +++ b/src/uu/numfmt/src/format.rs @@ -221,10 +221,9 @@ fn format_string( implicit_padding: Option, ) -> Result { // strip the (optional) suffix before applying any transformation - let source_without_suffix = if let Some(suffix) = &options.suffix { - source.strip_suffix(suffix).unwrap_or(source) - } else { - source + let source_without_suffix = match &options.suffix { + Some(suffix) => source.strip_suffix(suffix).unwrap_or(source), + None => source, }; let number = transform_to( @@ -234,10 +233,9 @@ fn format_string( )?; // bring back the suffix before applying padding - let number_with_suffix = if let Some(suffix) = &options.suffix { - format!("{}{}", number, suffix) - } else { - number + let number_with_suffix = match &options.suffix { + Some(suffix) => format!("{}{}", number, suffix), + None => number, }; Ok(match implicit_padding.unwrap_or(options.padding) {