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!
```
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib
```
This commit is contained in:
Mussar 2025-04-15 10:29:32 -05:00 committed by GitHub
parent a33650a69e
commit 2229370b13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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