add a test for FnMut
extern crate nom;
use nom::{
+ bytes::complete::tag,
error::ErrorKind,
+ multi::{many0, many0_count},
number::streaming::le_u64,
- multi::many0,
- bytes::complete::tag,
- Err, IResult, Needed,
+ Err, IResult, Needed, Parser,
};
#[test]
@@ -24,3 +24,20 @@ fn parse() {
println!("res: {:?}", res);
assert_eq!(counter, 5);
}
+
+#[test]
+fn accumulate() {
+ let mut v = Vec::new();
+
+ let (i, count) = {
+ let mut parser = many0_count::<_, _, (), _>(|i| {
+ let (i, o) = tag("abc")(i)?;
+ v.push(o);
+ Ok((i, ()))
+ });
+ parser("abcabcabcabc").unwrap()
+ };
+
+ println!("v: {:?}", v);
+ assert_eq!(v.len(), 4);
+}
