From 2229370b1360c0b3b93876f27122f73a705ceab8 Mon Sep 17 00:00:00 2001 From: Mussar <67082011+0x4D5352@users.noreply.github.com> Date: Tue, 15 Apr 2025 10:29:32 -0500 Subject: [PATCH] replace repeat().take() with repeat_n() (#15575) # Description This updates `string_expand()` in nu-table's util.rs to use the `std::iter` library's `repeat_n()` function, which was suggested as a more readable version of the existing `repeat().take()` implementation. # User-Facing Changes Should have no user facing changes. # Tests + Formatting All green circles! ``` - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib ``` --- crates/nu-table/src/util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/nu-table/src/util.rs b/crates/nu-table/src/util.rs index 8784454cfb..7ae7b61c76 100644 --- a/crates/nu-table/src/util.rs +++ b/crates/nu-table/src/util.rs @@ -32,7 +32,7 @@ pub fn string_wrap(text: &str, width: usize, keep_words: bool) -> String { } pub fn string_expand(text: &str, width: usize) -> String { - use std::{borrow::Cow, iter::repeat}; + use std::{borrow::Cow, iter::repeat_n}; use tabled::grid::util::string::{get_line_width, get_lines}; get_lines(text) @@ -42,7 +42,7 @@ pub fn string_expand(text: &str, width: usize) -> String { if length < width { let mut line = line.into_owned(); let remain = width - length; - line.extend(repeat(' ').take(remain)); + line.extend(repeat_n(' ', remain)); Cow::Owned(line) } else { line