From f8c1d2a9e8ebb7087d76c30c061c97adee44e72e Mon Sep 17 00:00:00 2001 From: tesuji <15225902+tesuji@users.noreply.github.com> Date: Thu, 11 Jul 2024 06:44:22 +0700 Subject: [PATCH] doc: Suggest `str::repeat` over `iter::repeat().take().collect()` --- library/core/src/iter/sources/repeat.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/core/src/iter/sources/repeat.rs b/library/core/src/iter/sources/repeat.rs index 0168b11c7394a..aaf7847199ed3 100644 --- a/library/core/src/iter/sources/repeat.rs +++ b/library/core/src/iter/sources/repeat.rs @@ -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.