[][src]Struct nommy::Buffer

pub struct Buffer<I: Iterator> { /* fields omitted */ }

Buffer is a wrapper around an Iterator, highly linked to Cursor

use nommy::Buffer;
let mut buffer = Buffer::new(0..);
let mut cursor1 = buffer.cursor();

// cursors act exactly like an iterator
assert_eq!(cursor1.next(), Some(0));
assert_eq!(cursor1.next(), Some(1));

// cursors can be made from other cursors
let mut cursor2 = cursor1.cursor();
assert_eq!(cursor2.next(), Some(2));
assert_eq!(cursor2.next(), Some(3));

// child cursors do not move the parent's iterator position
assert_eq!(cursor1.next(), Some(2));

// Same with the original buffer
assert_eq!(buffer.next(), Some(0));

Implementations

impl<I: Iterator> Buffer<I>[src]

pub fn new(iter: impl IntoIterator<IntoIter = I>) -> Self[src]

Create a new Buffer

pub fn cursor(&mut self) -> Cursor<'_, I>

Notable traits for Cursor<'a, I>

impl<'a, I: Iterator> Iterator for Cursor<'a, I> where
    I::Item: Clone
type Item = I::Item;
[src]

Create a Cursor over this buffer

Trait Implementations

impl<I: Iterator> Iterator for Buffer<I>[src]

type Item = I::Item

The type of the elements being iterated over.

Auto Trait Implementations

impl<I> RefUnwindSafe for Buffer<I> where
    I: RefUnwindSafe,
    <I as Iterator>::Item: RefUnwindSafe
[src]

impl<I> Send for Buffer<I> where
    I: Send,
    <I as Iterator>::Item: Send
[src]

impl<I> Sync for Buffer<I> where
    I: Sync,
    <I as Iterator>::Item: Sync
[src]

impl<I> Unpin for Buffer<I> where
    I: Unpin,
    <I as Iterator>::Item: Unpin
[src]

impl<I> UnwindSafe for Buffer<I> where
    I: UnwindSafe,
    <I as Iterator>::Item: UnwindSafe
[src]

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.