File tree 1 file changed +15
-3
lines changed
library/core/src/iter/traits
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -1825,10 +1825,19 @@ pub trait Iterator {
1825
1825
Inspect :: new ( self , f)
1826
1826
}
1827
1827
1828
- /// Borrows an iterator, rather than consuming it .
1828
+ /// Creates a "by reference" adapter for this instance of `Iterator` .
1829
1829
///
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).
1832
1841
///
1833
1842
/// # Examples
1834
1843
///
@@ -4024,6 +4033,9 @@ where
4024
4033
}
4025
4034
}
4026
4035
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.
4027
4039
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
4028
4040
impl < I : Iterator + ?Sized > Iterator for & mut I {
4029
4041
type Item = I :: Item ;
You can’t perform that action at this time.
0 commit comments