This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
library/core/src/iter/traits Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -1825,10 +1825,19 @@ pub trait Iterator {
18251825 Inspect :: new ( self , f)
18261826 }
18271827
1828- /// Borrows an iterator, rather than consuming it .
1828+ /// Creates a "by reference" adapter for this instance of `Iterator` .
18291829 ///
1830- /// This is useful to allow applying iterator adapters while still
1831- /// retaining ownership of the original iterator.
1830+ /// Consuming method calls (direct or indirect calls to `next`)
1831+ /// on the "by reference" adapter will consume the original iterator,
1832+ /// but ownership-taking methods (those with a `self` parameter)
1833+ /// only take ownership of the "by reference" iterator.
1834+ ///
1835+ /// This is useful for applying ownership-taking methods
1836+ /// (such as `take` in the example below)
1837+ /// without giving up ownership of the original iterator,
1838+ /// so you can use the original iterator afterwards.
1839+ ///
1840+ /// Uses [impl<I: Iterator + ?Sized> Iterator for &mut I { type Item = I::Item; ...}](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#impl-Iterator-for-%26mut+I).
18321841 ///
18331842 /// # Examples
18341843 ///
@@ -4024,6 +4033,9 @@ where
40244033 }
40254034}
40264035
4036+ /// Implements `Iterator` for mutable references to iterators, such as those produced by [`Iterator::by_ref`].
4037+ ///
4038+ /// This implementation passes all method calls on to the original iterator.
40274039#[ stable( feature = "rust1" , since = "1.0.0" ) ]
40284040impl < I : Iterator + ?Sized > Iterator for & mut I {
40294041 type Item = I :: Item ;
You can’t perform that action at this time.
0 commit comments