Merge pull request #4264 from cakebaker/pr_seq_simplify_format_strings

pr,seq: simplify format strings
This commit is contained in:
Terts Diepraam 2023-01-11 13:17:13 +01:00 committed by GitHub
commit 9ccfb025cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 17 deletions

View file

@ -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()

View file

@ -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)