1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-16 11:46:17 +00:00

refactor/printf ~ fix cargo clippy complaint (clippy::needless_borrow)

This commit is contained in:
Roy Ivy III 2021-06-05 23:28:19 -05:00
parent ad486a77dc
commit 750b68a44c
6 changed files with 8 additions and 8 deletions

View file

@ -26,7 +26,7 @@ impl Formatter for CninetyNineHexFloatf {
) -> Option<FormatPrimitive> {
let second_field = field.second_field.unwrap_or(6) + 1;
let analysis = FloatAnalysis::analyze(
&str_in,
str_in,
initial_prefix,
Some(second_field as usize),
None,

View file

@ -298,11 +298,11 @@ pub fn get_primitive_dec(
pub fn primitive_to_str_common(prim: &FormatPrimitive, field: &FormatField) -> String {
let mut final_str = String::new();
if let Some(ref prefix) = prim.prefix {
final_str.push_str(&prefix);
final_str.push_str(prefix);
}
match prim.pre_decimal {
Some(ref pre_decimal) => {
final_str.push_str(&pre_decimal);
final_str.push_str(pre_decimal);
}
None => {
panic!(

View file

@ -21,7 +21,7 @@ impl Formatter for Floatf {
) -> Option<FormatPrimitive> {
let second_field = field.second_field.unwrap_or(6) + 1;
let analysis = FloatAnalysis::analyze(
&str_in,
str_in,
initial_prefix,
None,
Some(second_field as usize),

View file

@ -252,7 +252,7 @@ impl Formatter for Intf {
fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String {
let mut final_str: String = String::new();
if let Some(ref prefix) = prim.prefix {
final_str.push_str(&prefix);
final_str.push_str(prefix);
}
// integral second fields is zero-padded minimum-width
// which gets handled before general minimum-width
@ -266,7 +266,7 @@ impl Formatter for Intf {
i -= 1;
}
}
final_str.push_str(&pre_decimal);
final_str.push_str(pre_decimal);
}
None => {
panic!(

View file

@ -235,7 +235,7 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option<St
let as_str = format!("{}", provided_num);
let initial_prefix = get_initial_prefix(
&as_str,
&field.field_type
field.field_type
);
tmp=formatter.get_primitive(field, &initial_prefix, &as_str)
.expect("err during default provided num");

View file

@ -275,7 +275,7 @@ impl SubParser {
}
None => {
text_so_far.push('%');
err_conv(&text_so_far);
err_conv(text_so_far);
false
}
}