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!(
|
format!(
|
||||||
"{:>width$}{}",
|
"{:>width$}{}",
|
||||||
&line_str[line_str.len() - width..],
|
&line_str[line_str.len() - width..],
|
||||||
separator,
|
separator
|
||||||
width = width
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!("{:>width$}{}", line_str, separator, width = width)
|
format!("{:>width$}{}", line_str, separator)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
|
|
|
@ -210,19 +210,9 @@ fn write_value_float(
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
let value_as_str =
|
let value_as_str =
|
||||||
if *value == ExtendedBigDecimal::Infinity || *value == ExtendedBigDecimal::MinusInfinity {
|
if *value == ExtendedBigDecimal::Infinity || *value == ExtendedBigDecimal::MinusInfinity {
|
||||||
format!(
|
format!("{value:>width$.precision$}")
|
||||||
"{value:>width$.precision$}",
|
|
||||||
value = value,
|
|
||||||
width = width,
|
|
||||||
precision = precision,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!("{value:>0width$.precision$}")
|
||||||
"{value:>0width$.precision$}",
|
|
||||||
value = value,
|
|
||||||
width = width,
|
|
||||||
precision = precision,
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
write!(writer, "{}", value_as_str)
|
write!(writer, "{}", value_as_str)
|
||||||
}
|
}
|
||||||
|
@ -237,9 +227,9 @@ fn write_value_int(
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
let value_as_str = if pad {
|
let value_as_str = if pad {
|
||||||
if *value == ExtendedBigInt::MinusZero && is_first_iteration {
|
if *value == ExtendedBigInt::MinusZero && is_first_iteration {
|
||||||
format!("-{value:>0width$}", value = value, width = width - 1,)
|
format!("-{value:>0width$}", width = width - 1)
|
||||||
} else {
|
} else {
|
||||||
format!("{value:>0width$}", value = value, width = width,)
|
format!("{value:>0width$}")
|
||||||
}
|
}
|
||||||
} else if *value == ExtendedBigInt::MinusZero && is_first_iteration {
|
} else if *value == ExtendedBigInt::MinusZero && is_first_iteration {
|
||||||
format!("-{}", value)
|
format!("-{}", value)
|
||||||
|
|
Loading…
Reference in a new issue