From cc1f1099062be477a8610956b5892f65e0399811 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 6 Jan 2023 10:36:58 +0100 Subject: [PATCH] pr,seq: simplify format strings --- src/uu/pr/src/pr.rs | 5 ++--- src/uu/seq/src/seq.rs | 18 ++++-------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index fac495e70..bf598c0bb 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -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() diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 1109bd093..e5784d771 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -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)