Struct pest::prelude::StringInput
[−]
[src]
pub struct StringInput<'a> { /* 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<'a> StringInput<'a>[src]
fn new(string: &'a str) -> StringInput<'a>
Creates a new StringInput from a &str.
Examples
let mut input = StringInput::new("asd"); assert_eq!(input.len(), 3);
Trait Implementations
impl<'a> Input<'a> for StringInput<'a>[src]
fn len(&self) -> usize
Returns length of an Input.
fn is_empty(&self) -> bool
Returns whether an Input is empty.
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) -> &'a 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