@@ -1825,10 +1825,20 @@ pub trait Iterator {
1825
1825
Inspect :: new ( self , f)
1826
1826
}
1827
1827
1828
- /// Borrows an iterator, rather than consuming it .
1828
+ /// Iterator adapter that turns ownership-taking methods into mutating methods .
1829
1829
///
1830
- /// This is useful to allow applying iterator adapters while still
1831
- /// retaining ownership of the original iterator.
1830
+ /// Most `Iterator` methods, other than the `next` method (and this one),
1831
+ /// take ownership (via a `self` parameter) of the iterator and then mutate it.
1832
+ /// This method retuns a mutable reference to the original iterator,
1833
+ /// that acts like the original iterator in all respects,
1834
+ /// except that ownership-taking methods take ownership of the reference instead of of the original.
1835
+ /// All mutation by ownership-taking methods will still mutate the original iterator.
1836
+ ///
1837
+ /// # Technical details
1838
+ ///
1839
+ /// The mutable reference that this method returns, implements the `Iterator` trait via:
1840
+ /// [impl<I: Iterator + ?Sized> Iterator for &mut I { type Item = I::Item; ...}](trait.Iterator.html#impl-Iterator-for-%26mut I).
1841
+ /// This implementation simply passes all method calls on to the original iterator.
1832
1842
///
1833
1843
/// # Examples
1834
1844
///
@@ -4019,6 +4029,7 @@ where
4019
4029
}
4020
4030
}
4021
4031
4032
+ /// Implements `Iterator` for mutable references to iterators, such as those produced by [`Iterator::by_ref`].
4022
4033
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
4023
4034
impl < I : Iterator + ?Sized > Iterator for & mut I {
4024
4035
type Item = I :: Item ;
0 commit comments