Skip to content

Commit 49632b9

Browse files
committed
Iterator::cloned: document side effect behavior
1 parent ddabe07 commit 49632b9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/core/src/iter/traits/iterator.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2998,6 +2998,11 @@ pub trait Iterator {
29982998
/// This is useful when you have an iterator over `&T`, but you need an
29992999
/// iterator over `T`.
30003000
///
3001+
/// Note that unlike copying, cloning is regarded as a side effect, because
3002+
/// `Clone` implementations may contain observable behavior. For example,
3003+
/// `iter.cloned().last()` will clone all elements even if only the last
3004+
/// one is actually returned.
3005+
///
30013006
/// [`clone`]: Clone::clone
30023007
///
30033008
/// # Examples

0 commit comments

Comments
 (0)