Skip to content

Commit cda24c6

Browse files
authored
Merge pull request #7400 from cakebaker/mktemp_tr_use_repeat_n
mktemp,tr: replace `repeat().take()` with `repeat_n()`
2 parents a82987b + da6d00b commit cda24c6

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/uu/mktemp/src/mktemp.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,7 @@ fn dry_exec(tmpdir: &Path, prefix: &str, rand: usize, suffix: &str) -> UResult<P
424424
let len = prefix.len() + suffix.len() + rand;
425425
let mut buf = Vec::with_capacity(len);
426426
buf.extend(prefix.as_bytes());
427-
// In Rust v1.82.0, use `repeat_n`:
428-
// <https://doc.rust-lang.org/std/iter/fn.repeat_n.html>
429-
buf.extend(iter::repeat(b'X').take(rand));
427+
buf.extend(iter::repeat_n(b'X', rand));
430428
buf.extend(suffix.as_bytes());
431429

432430
// Randomize.

src/uu/tr/src/operation.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ impl Sequence {
132132
Self::Char(c) => Box::new(std::iter::once(*c)),
133133
Self::CharRange(l, r) => Box::new(*l..=*r),
134134
Self::CharStar(c) => Box::new(std::iter::repeat(*c)),
135-
// In Rust v1.82.0, use `repeat_n`:
136-
// <https://doc.rust-lang.org/std/iter/fn.repeat_n.html>
137-
Self::CharRepeat(c, n) => Box::new(std::iter::repeat(*c).take(*n)),
135+
Self::CharRepeat(c, n) => Box::new(std::iter::repeat_n(*c, *n)),
138136
Self::Class(class) => match class {
139137
Class::Alnum => Box::new((b'0'..=b'9').chain(b'A'..=b'Z').chain(b'a'..=b'z')),
140138
Class::Alpha => Box::new((b'A'..=b'Z').chain(b'a'..=b'z')),

0 commit comments

Comments
 (0)