From 05bf6bcfaeb7b3803f0a3a79c273e6ee8b5ff3a8 Mon Sep 17 00:00:00 2001 From: tesuji <15225902+tesuji@users.noreply.github.com> Date: Sun, 14 Jul 2024 00:51:08 +0000 Subject: [PATCH] doc: Suggest `str::repeat` over `iter::repeat().take().collect()` Using ../../std syntax because of difficulty link alloc stuff to core. --- core/src/iter/sources/repeat.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/iter/sources/repeat.rs b/core/src/iter/sources/repeat.rs index 0168b11c7394a..243f938bce2af 100644 --- a/core/src/iter/sources/repeat.rs +++ b/core/src/iter/sources/repeat.rs @@ -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 ///