Skip to content

Commit 3f38594

Browse files
authored
doc: Suggest str::repeat over iter::repeat().take().collect()
1 parent 0c81f94 commit 3f38594

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ use crate::num::NonZero;
77
///
88
/// Infinite iterators like `repeat()` are often used with adapters like
99
/// [`Iterator::take()`], in order to make them finite.
10+
///
11+
/// > Please prefer [`str::repeat()`] over this function if you just want
12+
/// > to repeat a char/string `n`th times.
1013
///
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

0 commit comments

Comments
 (0)