refactor: Fix clippy warnings (#488)

* refactor: Use `repeat_n` instead of `repeat` and `take`

Fixes `clippy::manual_repeat_n`

* refactor: Remove unnecessary let binding
This commit is contained in:
Teemu Pätsi
2025-04-20 20:48:11 +03:00
committed by GitHub
parent b616378ba0
commit 4e2d93f362

View File

@@ -12,7 +12,7 @@ use chrono::{DateTime, Local, TimeZone, Utc};
use std::cmp::max;
use std::cmp::min;
use std::fs;
use std::iter::repeat;
use std::iter::repeat_n;
use std::path::Path;
use thousands::Separable;
@@ -155,7 +155,7 @@ pub fn draw_it(
allowed_width - longest_string_length - 7
};
let first_size_bar = repeat(BLOCKS[0]).take(max_bar_length).collect();
let first_size_bar = repeat_n(BLOCKS[0], max_bar_length).collect();
let display_data = DisplayData {
initial: idd,
@@ -298,12 +298,9 @@ fn pad_or_trim_filename(node: &DisplayNode, indent: &str, display_data: &Display
);
// Add spaces after the filename so we can draw the % used bar chart.
let name_and_padding = name
+ " "
name + " "
.repeat(display_data.longest_string_length - width)
.as_str();
name_and_padding
.as_str()
}
fn maybe_trim_filename(name_in: String, indent: &str, display_data: &DisplayData) -> String {
@@ -594,7 +591,7 @@ mod tests {
size: 2_u64.pow(size),
children: vec![],
};
let first_size_bar = repeat(BLOCKS[0]).take(13).collect();
let first_size_bar = repeat_n(BLOCKS[0], 13).collect();
let dd = DrawData {
indent: "".into(),
percent_bar: first_size_bar,