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

View file

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