From 49632b98d509469949cf082c19df9566ca22d2b7 Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Mon, 3 Jan 2022 23:48:16 +0100 Subject: [PATCH] `Iterator::cloned`: document side effect behavior --- library/core/src/iter/traits/iterator.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 9a9a844f41bb4..e13fcf7955246 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -2998,6 +2998,11 @@ pub trait Iterator { /// This is useful when you have an iterator over `&T`, but you need an /// iterator over `T`. /// + /// Note that unlike copying, cloning is regarded as a side effect, because + /// `Clone` implementations may contain observable behavior. For example, + /// `iter.cloned().last()` will clone all elements even if only the last + /// one is actually returned. + /// /// [`clone`]: Clone::clone /// /// # Examples