Trait pest::Input [] [src]

pub trait Input {
    fn len(&self) -> usize;
    fn pos(&self) -> usize;
    fn set_pos(&mut self, pos: usize);
    fn slice(&self, start: usize, end: usize) -> &str;
    fn line_col(&self, pos: usize) -> (usize, usize);
    fn match_string(&mut self, string: &str) -> bool;
    fn match_range(&mut self, left: char, right: char) -> bool;
}

A trait that defines an input for a Parser.

Required Methods

fn len(&self) -> usize

Returns length of an Input.

fn pos(&self) -> usize

Returns current position of an Input.

fn set_pos(&mut self, pos: usize)

Set current position of an Input.

fn slice(&self, start: usize, end: usize) -> &str

Slices an Input.

fn line_col(&self, pos: usize) -> (usize, usize)

Returns the line and column of a position for an Input.

fn match_string(&mut self, string: &str) -> bool

Matches string to an Input, returns whether it matched, and advances the position with string.len() in case it did.

fn match_range(&mut self, left: char, right: char) -> bool

Matches if an Input's current char is between left and right, and advances the position with one char in case it did.

Implementors