[−][src]Macro nom::many1
many1!(I -> IResult<I,O>) => I -> IResult<I, Vec<O>>
Applies the parser 1 or more times and returns the list of results in a Vec
the embedded parser may return Incomplete
named!(multi<&[u8], Vec<&[u8]> >, many1!( tag!( "abcd" ) ) ); let a = b"abcdabcdefgh"; let b = b"azerty"; let res = vec![&b"abcd"[..], &b"abcd"[..]]; assert_eq!(multi(&a[..]), Ok((&b"efgh"[..], res))); assert_eq!(multi(&b[..]), Err(Err::Error(error_position!(&b[..], ErrorKind::Many1)))); named!(multi_complete<CompleteByteSlice, Vec<CompleteByteSlice> >, many1!( tag!( "abcd" ) ) ); let c = CompleteByteSlice(b"abcdabcd"); let res = vec![CompleteByteSlice(b"abcd"), CompleteByteSlice(b"abcd")]; assert_eq!(multi_complete(c), Ok((CompleteByteSlice(b""), res)));