mirror of
https://github.com/nushell/nushell.git
synced 2025-05-18 08:50:47 +02:00
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:
parent
a33650a69e
commit
2229370b13
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user