Trait parsell::UncommittedStr [] [src]

pub trait UncommittedStr<'a>: Uncommitted<charChars<'a>> {
    fn init_str(&self, string: &'a str) -> Option<ParseResult<Self::State, Self::Output>> where Self: Sized { ... }
}

A trait for uncommitted string parsers.

Provided Methods

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

Provides string data to the parser.

If parser: Uncommitted<char, Chars<'a>> and data: &'a str, then parser.init_str(data) is short-hand for parser.init(&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"),
}

Implementors