Skip to content

Commit f8c1d2a

Browse files
committed
doc: Suggest str::repeat over iter::repeat().take().collect()
1 parent 0c81f94 commit f8c1d2a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ 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+
/// > Please prefer [`str::repeat()`] over this function if you just want
12+
/// > to repeat 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.

0 commit comments

Comments
 (0)