#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct Peekable<I: Iterator> {
// some fields omitted
}
An iterator with a peek()
that returns an optional reference to the next element.
Methods
fn peek(&mut self) -> Option<&I::Item>
Returns a reference to the next element of the iterator with out
advancing it, or None if the iterator is exhausted.
Unstable
Checks whether peekable iterator is empty or not.
Trait Implementations
type Item = I::Item
fn next(&mut self) -> Option<I::Item>
fn nth(&mut self, n: usize) -> Option<I::Item>
fn last(self) -> Option<I::Item>
fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter> where Self: Sized, U: IntoIterator<Item=Self::Item>
fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter> where Self: Sized, U: IntoIterator
fn map<B, F>(self, f: F) -> Map<Self, F> where Self: Sized, F: FnMut(Self::Item) -> B
fn filter<P>(self, predicate: P) -> Filter<Self, P> where Self: Sized, P: FnMut(&Self::Item) -> bool
fn skip(self, n: usize) -> Skip<Self> where Self: Sized
fn take(self, n: usize) -> Take<Self> where Self: Sized
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>
fn fuse(self) -> Fuse<Self> where Self: Sized
fn inspect<F>(self, f: F) -> Inspect<Self, F> where Self: Sized, F: FnMut(&Self::Item)
fn by_ref(&mut self) -> &mut Self where Self: Sized
fn fold<B, F>(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B
fn all<F>(&mut self, f: F) -> bool where Self: Sized, F: FnMut(Self::Item) -> bool
fn any<F>(&mut self, f: F) -> bool where Self: Sized, F: FnMut(Self::Item) -> bool
fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where Self: Sized, P: FnMut(&Self::Item) -> bool
fn max_by<B: Ord, F>(self, f: F) -> Option<Self::Item> where Self: Sized, F: FnMut(&Self::Item) -> B
fn min_by<B: Ord, F>(self, f: F) -> Option<Self::Item> where Self: Sized, F: FnMut(&Self::Item) -> B
fn cloned<'a, T: 'a>(self) -> Cloned<Self> where Self: Sized + Iterator<Item=&'a T>, T: Clone
fn sum<S = Self::Item>(self) -> S where S: Add<Self::Item, Output=S> + Zero, Self: Sized
fn product<P = Self::Item>(self) -> P where P: Mul<Self::Item, Output=P> + One, Self: Sized
Keyboard shortcuts
- ?
- Show this help dialog
- S
- Focus the search field
- ⇤
- Move up in search results
- ⇥
- Move down in search results
- ⏎
- Go to active search result
Search tricks
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
, enum
,
trait
, typedef
(or
tdef
).
Search functions by type signature (e.g.
vec -> usize
)