Struct pest::StringInput [] [src]

pub struct StringInput {
    // some fields omitted
}

A struct useful for matching in-memory Strings.

Examples

let mut input = StringInput::new("asdasdf");

assert!(input.match_string("asd"));
assert!(input.match_string("asdf"));
assert!(!input.match_string("nope"));

Methods

impl StringInput
[src]

fn new(string: &str) -> StringInput

Creates a new StringInput from a &str.

Examples

let mut input = StringInput::new("asd");

assert_eq!(input.len(), 3);

Trait Implementations

impl Input for StringInput
[src]

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

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