1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

numfmt: replace if let with simpler match

This commit is contained in:
Sebastian Holgersson 2022-01-02 02:16:59 +01:00
parent 84798a520e
commit a3895bba59

View file

@ -221,10 +221,9 @@ fn format_string(
implicit_padding: Option<isize>,
) -> Result<String> {
// 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) {