nom::many0!
[−]
[src]
macro_rules! many0( ($i:expr, $submac:ident!( $($args:tt)* )) => ( { let mut begin = 0; let mut remaining = $i.len(); let mut res = Vec::new(); loop { match $submac!(&$i[begin..], $($args)*) { $crate::IResult::Done(i,o) => { if i.len() == $i[begin..].len() { break; } res.push(o); begin += remaining - i.len(); remaining = i.len(); }, _ => { break; } } } $crate::IResult::Done(&$i[begin..], res) } ); ($i:expr, $f:expr) => ( many0!($i, call!($f)); ); );
many0!(I -> IResult<I,O>) => I -> IResult<I, Vec<O>>
Applies the parser 0 or more times and returns the list of results in a Vec
the embedded parser may return Incomplete
named!(multi<&[u8], Vec<&[u8]> >, many0!( tag!( "abcd" ) ) ); let a = b"abcdabcdef"; let b = b"azerty"; let res = vec![&b"abcd"[..], &b"abcd"[..]]; assert_eq!(multi(&a[..]), Done(&b"ef"[..], res)); assert_eq!(multi(&b[..]), Done(&b"azerty"[..], Vec::new()));
0 or more