Commit 506c304 1 parent 061ee95 commit 506c304 Copy full SHA for 506c304
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
///
@@ -4019,6 +4028,9 @@ where
4019
4028
}
4020
4029
}
4021
4030
4031
+ /// Implements `Iterator` for mutable references to iterators, such as those produced by [`Iterator::by_ref`].
4032
+ ///
4033
+ /// This implementation passes all method calls on to the original iterator.
4022
4034
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
4023
4035
impl < I : Iterator + ?Sized > Iterator for & mut I {
4024
4036
type Item = I :: Item ;
You can’t perform that action at this time.
0 commit comments