Rollup merge of #127592 - tesuji:patch-1, r=Mark-Simulacrum

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

r? libs
This commit is contained in:
Matthias Krüger 2024-07-14 20:24:59 +02:00 committed by GitHub
commit 77d25b9f9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,11 +8,15 @@ use crate::num::NonZero;
/// 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
///