From 4e2d93f3623be6a1c14a275407b3dca1e42eef42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teemu=20P=C3=A4tsi?= <44954973+frendsick@users.noreply.github.com> Date: Sun, 20 Apr 2025 20:48:11 +0300 Subject: [PATCH] refactor: Fix clippy warnings (#488) * refactor: Use `repeat_n` instead of `repeat` and `take` Fixes `clippy::manual_repeat_n` * refactor: Remove unnecessary let binding --- src/display.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/display.rs b/src/display.rs index a6a1b37..e1736ae 100644 --- a/src/display.rs +++ b/src/display.rs @@ -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 - + " " - .repeat(display_data.longest_string_length - width) - .as_str(); - - name_and_padding + name + " " + .repeat(display_data.longest_string_length - width) + .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,