[][src]Struct libslide::utils::iter::PeekIter

pub struct PeekIter<T> where
    T: Clone
{ iter: IntoIter<T>, lookahead: VecDeque<Option<T>>, }

An iterator that supports arbitrary-length peeking.

This struct is a beefed-up version of rustlib's Peekable, which supports only peeking at the next item in an iterator. Multi-length peeks may be required by applications that need to establish a context; for example, a parser.

Fields

iter: IntoIter<T>lookahead: VecDeque<Option<T>>

A store of items we had to consume from the iterator for peeking.

Implementations

impl<T> PeekIter<T> where
    T: Clone
[src]

pub fn new(iter: IntoIter<T>) -> Self[src]

pub fn peek(&mut self) -> Option<&T>[src]

Returns a reference to the next value in the iterator, without consuming it, or None if the iteration is complete.

pub fn peek_map_n<R>(&mut self, n: usize, f: fn(_: &T) -> R) -> VecDeque<R>[src]

Returns a deque of up to n peeked items mapped over a function f.

The length of the returned deque is n or the number of items remaining in the iteration, whichever is lower.

pub fn push_front(&mut self, item: T)[src]

Adds an item to the front of the current iteration.

Trait Implementations

impl<T> Iterator for PeekIter<T> where
    T: Clone
[src]

type Item = T

The type of the elements being iterated over.

Auto Trait Implementations

impl<T> RefUnwindSafe for PeekIter<T> where
    T: RefUnwindSafe

impl<T> Send for PeekIter<T> where
    T: Send

impl<T> Sync for PeekIter<T> where
    T: Sync

impl<T> Unpin for PeekIter<T> where
    T: Unpin

impl<T> UnwindSafe for PeekIter<T> where
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.