Struct nommy::Cursor[][src]

pub struct Cursor<'a, T, B: Buffer<T>> { /* fields omitted */ }

Cursor is a Buffer that non-destructively reads from it's parent's buffer using Buffer::peek_ahead See Buffer documentation for example usage

Implementations

impl<'a, T, B: Buffer<T>> Cursor<'a, T, B>[src]

pub fn fast_forward_parent(self)[src]

Drops this cursor and calls Buffer::fast_forward on the parent buffer

use nommy::{Buffer, IntoBuf};
let mut input = "foobar".chars().into_buf();
let mut cursor = input.cursor();
assert_eq!(cursor.next(), Some('f'));
assert_eq!(cursor.next(), Some('o'));
assert_eq!(cursor.next(), Some('o'));

// Typically, the next three calls to `next` would repeat
// the first three calls because cursors read non-destructively.
// However, this method allows to drop the already-read contents
cursor.fast_forward_parent();
assert_eq!(input.next(), Some('b'));
assert_eq!(input.next(), Some('a'));
assert_eq!(input.next(), Some('r'));

Trait Implementations

impl<'a, T, B: Buffer<T>> Buffer<T> for Cursor<'a, T, B>[src]

impl<'a, T, B: Buffer<T>> Iterator for Cursor<'a, T, B>[src]

type Item = T

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a, T, B> RefUnwindSafe for Cursor<'a, T, B> where
    B: RefUnwindSafe,
    T: RefUnwindSafe
[src]

impl<'a, T, B> Send for Cursor<'a, T, B> where
    B: Send,
    T: Send
[src]

impl<'a, T, B> Sync for Cursor<'a, T, B> where
    B: Sync,
    T: Sync
[src]

impl<'a, T, B> Unpin for Cursor<'a, T, B> where
    T: Unpin
[src]

impl<'a, T, B> !UnwindSafe for Cursor<'a, T, B>[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.