Remove aux variable and assign output to format! directly.

This commit is contained in:
Hiers 2023-03-05 15:05:10 +00:00
parent 6ad4c5cdc3
commit d067e01bd4

View file

@ -153,8 +153,7 @@ fn print_item(query: &str, value: &Value, output: &mut String) -> Option<usize>
let main_form = japanese.get(0)?; let main_form = japanese.get(0)?;
let mut num_of_lines = 0; let mut num_of_lines = 0;
let mut aux = format!("{} {}\n", format_form(query, main_form)?, format_result_tags(value)); *output += &format!("{} {}\n", format_form(query, main_form)?, format_result_tags(value));
*output += &aux;
// Print senses // Print senses
let senses = value_to_arr(value.get("senses")?); let senses = value_to_arr(value.get("senses")?);
@ -170,8 +169,7 @@ fn print_item(query: &str, value: &Value, output: &mut String) -> Option<usize>
num_of_lines += 1; num_of_lines += 1;
} }
aux = format!(" {}\n", sense_str); *output += &format!(" {}\n", sense_str);
*output += &aux;
} }
// Print alternative readings and kanji usage // Print alternative readings and kanji usage
@ -181,12 +179,10 @@ fn print_item(query: &str, value: &Value, output: &mut String) -> Option<usize>
*output += &format!(" {}", "Other forms\n".bright_blue()); *output += &format!(" {}", "Other forms\n".bright_blue());
aux = format!(" {}", format_form(query, form)?); *output += &format!(" {}", format_form(query, form)?);
*output += &aux;
for form in japanese.get(2).iter() { for form in japanese.get(2).iter() {
aux = format!(", {}", format_form(query, form)?); *output += &format!(", {}", format_form(query, form)?);
*output += &aux;
} }
output.push('\n'); output.push('\n');
} }