Skip to content

Commit affaf53

Browse files
committed
referring to repeat_n in std::iter::repeat
1 parent 1654cce commit affaf53

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ 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+
/// If you know the number of repetitions in advance, consider using [`repeat_n()`]
12+
/// instead, as it is more efficient and conveys the intent more clearly.
13+
///
1114
/// Use [`str::repeat()`] instead of this function if you just want to repeat
1215
/// a char/string `n` times.
1316
///
1417
/// If the element type of the iterator you need does not implement `Clone`,
1518
/// or if you do not want to keep the repeated element in memory, you can
1619
/// instead use the [`repeat_with()`] function.
1720
///
21+
/// [`repeat_n()`]: crate::iter::repeat_n
1822
/// [`repeat_with()`]: crate::iter::repeat_with
1923
/// [`str::repeat()`]: ../../std/primitive.str.html#method.repeat
2024
///

0 commit comments

Comments
 (0)