Commit b1484f5 1 parent 061ee95 commit b1484f5 Copy full SHA for b1484f5
File tree 1 file changed +10
-3
lines changed
library/core/src/iter/traits
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1825,10 +1825,16 @@ pub trait Iterator {
1825
1825
Inspect :: new ( self , f)
1826
1826
}
1827
1827
1828
- /// Borrows an iterator, rather than consuming it.
1828
+ /// If you use a consuming method on an iterator,
1829
+ /// the iterator is consumed by the method and cannot be used afterwards.
1830
+ /// This method allows you to mutably borrow an iterator,
1831
+ /// such that consuming methods don't consume the original.
1829
1832
///
1830
- /// This is useful to allow applying iterator adapters while still
1831
- /// retaining ownership of the original iterator.
1833
+ /// This turns an iterator into its mutably-borrowed iterator via
1834
+ /// [impl<I: Iterator + ?Sized> Iterator for &mut I { type Item = I::Item; ...}](trait.Iterator.html#impl-Iterator-for-&mut I).
1835
+ /// This allows using consuming methods on the mutable borrow,
1836
+ /// which then consume the mutable borrow instead of the original,
1837
+ /// such that you can continue to use the original iterator afterwards.
1832
1838
///
1833
1839
/// # Examples
1834
1840
///
@@ -4019,6 +4025,7 @@ where
4019
4025
}
4020
4026
}
4021
4027
4028
+ /// Implements Iterator for mutable references to Iterator, such as those produced by [Iterator::by_ref]
4022
4029
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
4023
4030
impl < I : Iterator + ?Sized > Iterator for & mut I {
4024
4031
type Item = I :: Item ;
You can’t perform that action at this time.
0 commit comments