[][src]Struct generic_lexer::BufferedInput

pub struct BufferedInput<'a> { /* fields omitted */ }

Methods

impl<'a> BufferedInput<'a>[src]

pub fn take_buffer(&mut self) -> String[src]

Copy out the buffer and clear it

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

Peek at the next character

pub fn skip(&mut self) -> Option<char>[src]

Get the next character but don't push it to the buffer

pub fn skip_if<P: Fn(&char) -> bool>(&mut self, predicate: P) -> Option<char>[src]

Skip if the given predicate is true

pub fn skip_while<P: Fn(&char) -> bool>(&mut self, predicate: P)[src]

Skip while the given predicate is true

pub fn accept(&mut self) -> Option<char>[src]

Retrieve the next character and increment the input position

pub fn accept_if<P: Fn(&char) -> bool>(&mut self, predicate: P) -> Option<char>[src]

Call self.next() if the peeked character is identical to b

pub fn accept_while<P: Fn(&char) -> bool>(&mut self, predicate: P)[src]

Call self.next() while the peeked character fulfils predicate

pub fn accept_or<P: Fn(&char) -> bool, T>(
    &mut self,
    predicate: P,
    ok: T,
    default: T
) -> T
[src]

Accept the given byte and return ok, or else return default

This is useful for matching multi-character tokens:

match c {
    '=' => input.accept_or(|&c| c == '=', TokenKind::DoubleEquals, TokenKind::Equals),
    _ => {},
}

pub fn skip_whitespace(&mut self)[src]

Skip whitespace, preserving the original buffer before any whitespace was encountered

Auto Trait Implementations

impl<'a> RefUnwindSafe for BufferedInput<'a>

impl<'a> Send for BufferedInput<'a>

impl<'a> Sync for BufferedInput<'a>

impl<'a> Unpin for BufferedInput<'a>

impl<'a> UnwindSafe for BufferedInput<'a>

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<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.