Trait parsell::StatefulStr [] [src]

pub trait StatefulStr<'a>: StatefulInfer<charChars<'a>> {
    fn more_str(self, string: &'a str) -> ParseResult<Self, Self::Output> where Self: Sized { ... }
    fn last_str(self, string: &'a str) -> Self::Output where Self: Sized { ... }
}

A trait for stateful string parsers.

Provided Methods

fn more_str(self, string: &'a str) -> ParseResult<Self, Self::Output> where Self: Sized

Provides a string to the parser.

If parser: StatefulInfer<char, Chars<'a>> and data: &'a str, then parser.more_str(data) is short-hand for parser.more(&mut data.chars()).

For example:

let parser = character(char::is_alphabetic).star(String::new);
match parser.init_str("ab").unwrap() {
    Continue(stateful) => match stateful.more_str("cd") {
        Continue(stateful) => match stateful.more_str("ef!") {
            Done(result) => assert_eq!(result, "abcdef"),
            _ => panic!("can't happen"),
        },
        _ => panic!("can't happen"),
    },
    _ => panic!("can't happen"),
}

fn last_str(self, string: &'a str) -> Self::Output where Self: Sized

Provides the last string to the parser.

If parser: StatefulInfer<char, Chars<'a>> and data: &'a str, then parser.last_str(data) is short-hand for parser.last(&mut data.chars()).

For example:

let parser = character(char::is_alphabetic).star(String::new);
match parser.init_str("ab").unwrap() {
    Continue(parsing) => match parsing.more_str("cd") {
        Continue(parsing) => assert_eq!(parsing.last_str("ef"),"abcdef"),
        _ => panic!("can't happen"),
    },
    _ => panic!("can't happen"),
}

Implementors