mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
numfmt: replace if let with simpler match
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user