File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
library/core/src/iter/traits Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 11#[ unstable( feature = "peekable_iterator" , issue = "132973" ) ]
2- /// Iterators which inherently support `peek()` without needing to be wrapped by a `Peekable`.
2+ /// Iterators which inherently support peeking without needing to be wrapped by a `Peekable`.
33pub trait PeekableIterator : Iterator {
4- /// executes the closure with an Option containing `None` if the iterator is exhausted or Some(&Self::Item)
4+ /// Executes the closure with a reference to the `next()` value without advancing the iterator.
55 fn peek_with < T > ( & mut self , func : impl for < ' a > FnOnce ( Option < & ' a Self :: Item > ) -> T ) -> T ;
66
7- /// executes the closure on the next element without advancing the iterator, or returns None if the iterator is exhausted.
7+ /// Executes the closure on the ` next()` element without advancing the iterator, or returns ` None` if the iterator is exhausted.
88 fn peek_map < T > ( & mut self , func : impl for < ' a > FnOnce ( & ' a Self :: Item ) -> T ) -> Option < T > {
99 self . peek_with ( |x| x. map ( |y| func ( y) ) )
1010 }
1111
12- /// returns the `next()` element if a predicate holds true
12+ /// Returns the `next()` element if the given predicate holds true.
1313 fn next_if ( & mut self , func : impl FnOnce ( & Self :: Item ) -> bool ) -> Option < Self :: Item > {
1414 self . peek_map ( func) . and_then ( |_| self . next ( ) )
1515 }
1616
17- /// move forward and return the `next()` item if it is equal to the expected value
17+ /// Moves forward and return the `next()` item if it is equal to the expected value.
1818 fn next_if_eq < T > ( & mut self , expected : & T ) -> Option < Self :: Item >
1919 where
2020 Self :: Item : PartialEq < T > ,
You can’t perform that action at this time.
0 commit comments