mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 15:22:38 +00:00
Merge pull request #4264 from cakebaker/pr_seq_simplify_format_strings
pr,seq: simplify format strings
This commit is contained in:
commit
9ccfb025cf
2 changed files with 6 additions and 17 deletions
|
@ -1200,11 +1200,10 @@ fn get_formatted_line_number(opts: &OutputOptions, line_number: usize, index: us
|
|||
format!(
|
||||
"{:>width$}{}",
|
||||
&line_str[line_str.len() - width..],
|
||||
separator,
|
||||
width = width
|
||||
separator
|
||||
)
|
||||
} else {
|
||||
format!("{:>width$}{}", line_str, separator, width = width)
|
||||
format!("{:>width$}{}", line_str, separator)
|
||||
}
|
||||
} else {
|
||||
String::new()
|
||||
|
|
|
@ -210,19 +210,9 @@ fn write_value_float(
|
|||
) -> std::io::Result<()> {
|
||||
let value_as_str =
|
||||
if *value == ExtendedBigDecimal::Infinity || *value == ExtendedBigDecimal::MinusInfinity {
|
||||
format!(
|
||||
"{value:>width$.precision$}",
|
||||
value = value,
|
||||
width = width,
|
||||
precision = precision,
|
||||
)
|
||||
format!("{value:>width$.precision$}")
|
||||
} else {
|
||||
format!(
|
||||
"{value:>0width$.precision$}",
|
||||
value = value,
|
||||
width = width,
|
||||
precision = precision,
|
||||
)
|
||||
format!("{value:>0width$.precision$}")
|
||||
};
|
||||
write!(writer, "{}", value_as_str)
|
||||
}
|
||||
|
@ -237,9 +227,9 @@ fn write_value_int(
|
|||
) -> std::io::Result<()> {
|
||||
let value_as_str = if pad {
|
||||
if *value == ExtendedBigInt::MinusZero && is_first_iteration {
|
||||
format!("-{value:>0width$}", value = value, width = width - 1,)
|
||||
format!("-{value:>0width$}", width = width - 1)
|
||||
} else {
|
||||
format!("{value:>0width$}", value = value, width = width,)
|
||||
format!("{value:>0width$}")
|
||||
}
|
||||
} else if *value == ExtendedBigInt::MinusZero && is_first_iteration {
|
||||
format!("-{}", value)
|
||||
|
|
Loading…
Reference in a new issue