extern crate pom_trace; use pom_trace::parser::*; use pom_trace::Parser; fn spaces() -> Parser { one_of(b" ").repeat(1..).discard() } fn works() -> Parser> { list(one_of(b"abc"), spaces() * seq(b"and") - spaces()) } fn dangle() -> Parser, &'static [u8])> { list(one_of(b"abc"), spaces() * seq(b"and") - spaces()) + seq(b" and") } #[test] fn test_list() { let one = b"a and b and c"; assert_eq!(works().parse(one), Ok(vec![b'a', b'b', b'c'])); let two = b"a and b and c and "; assert_eq!( dangle().parse(two), Ok((vec![b'a', b'b', b'c'], &b" and"[..])) ); }