mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
numfmt: replace if let with simpler match
This commit is contained in:
parent
84798a520e
commit
a3895bba59
1 changed files with 6 additions and 8 deletions
|
@ -221,10 +221,9 @@ fn format_string(
|
||||||
implicit_padding: Option<isize>,
|
implicit_padding: Option<isize>,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
// strip the (optional) suffix before applying any transformation
|
// strip the (optional) suffix before applying any transformation
|
||||||
let source_without_suffix = if let Some(suffix) = &options.suffix {
|
let source_without_suffix = match &options.suffix {
|
||||||
source.strip_suffix(suffix).unwrap_or(source)
|
Some(suffix) => source.strip_suffix(suffix).unwrap_or(source),
|
||||||
} else {
|
None => source,
|
||||||
source
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let number = transform_to(
|
let number = transform_to(
|
||||||
|
@ -234,10 +233,9 @@ fn format_string(
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// bring back the suffix before applying padding
|
// bring back the suffix before applying padding
|
||||||
let number_with_suffix = if let Some(suffix) = &options.suffix {
|
let number_with_suffix = match &options.suffix {
|
||||||
format!("{}{}", number, suffix)
|
Some(suffix) => format!("{}{}", number, suffix),
|
||||||
} else {
|
None => number,
|
||||||
number
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(match implicit_padding.unwrap_or(options.padding) {
|
Ok(match implicit_padding.unwrap_or(options.padding) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue