android13/external/rust/crates/combine/examples
liiir1985 7f62dcda9f initial 2024-06-22 20:45:49 +08:00
..
async.rs initial 2024-06-22 20:45:49 +08:00
date.rs initial 2024-06-22 20:45:49 +08:00
ini.rs initial 2024-06-22 20:45:49 +08:00
number.rs initial 2024-06-22 20:45:49 +08:00
readme.rs initial 2024-06-22 20:45:49 +08:00

readme.rs

use combine::{
    many1,
    parser::char::{letter, space},
    sep_by, Parser,
};

#[test]
fn readme() {
    main();
}

fn main() {
    let word = many1(letter());

    let mut parser = sep_by(word, space()).map(|mut words: Vec<String>| words.pop());
    let result = parser.parse("Pick up that word!");
    assert_eq!(result, Ok((Some("word".to_string()), "!")));
}