Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6c4029a

Browse files
authoredJul 14, 2024
Rollup merge of rust-lang#127592 - tesuji:patch-1, r=Mark-Simulacrum
doc: Suggest `str::repeat` over `iter::repeat().take().collect()` r? libs
2 parents 54435f7 + 05bf6bc commit 6c4029a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎core/src/iter/sources/repeat.rs

+4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ use crate::num::NonZero;
88
/// Infinite iterators like `repeat()` are often used with adapters like
99
/// [`Iterator::take()`], in order to make them finite.
1010
///
11+
/// Use [`str::repeat()`] instead of this function if you just want to repeat
12+
/// a char/string `n`th times.
13+
///
1114
/// If the element type of the iterator you need does not implement `Clone`,
1215
/// or if you do not want to keep the repeated element in memory, you can
1316
/// instead use the [`repeat_with()`] function.
1417
///
1518
/// [`repeat_with()`]: crate::iter::repeat_with
19+
/// [`str::repeat()`]: ../../std/primitive.str.html#method.repeat
1620
///
1721
/// # Examples
1822
///

0 commit comments

Comments
 (0)
Failed to load comments.