Skip to content

Commit

Permalink
doc: Suggest str::repeat over iter::repeat().take().collect()
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Jul 11, 2024
1 parent 0c81f94 commit f8c1d2a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/core/src/iter/sources/repeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use crate::num::NonZero;
/// Infinite iterators like `repeat()` are often used with adapters like
/// [`Iterator::take()`], in order to make them finite.
///
/// > Please prefer [`str::repeat()`] over this function if you just want
/// > to repeat a char/string `n`th times.
///
/// If the element type of the iterator you need does not implement `Clone`,
/// or if you do not want to keep the repeated element in memory, you can
/// instead use the [`repeat_with()`] function.
Expand Down

0 comments on commit f8c1d2a

Please sign in to comment.