doc: Suggest str::repeat over iter::repeat().take().collect()

Using ../../std syntax because of difficulty link alloc stuff to core.
This commit is contained in:
tesuji 2024-07-14 00:51:08 +00:00 committed by Lzu Tao
parent 0c81f94b9a
commit 193767e650

View File

@ -8,11 +8,15 @@
/// Infinite iterators like `repeat()` are often used with adapters like
/// [`Iterator::take()`], in order to make them finite.
///
/// Use [`str::repeat()`] instead of 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.
///
/// [`repeat_with()`]: crate::iter::repeat_with
/// [`str::repeat()`]: ../../std/primitive.str.html#method.repeat
///
/// # Examples
///