use fold_many0c in the fold_many0 macro

This commit is contained in:
Geoffroy Couprie 2020-10-25 16:52:40 +01:00
parent b7e201fe84
commit 6168f7b7e1
2 changed files with 11 additions and 1 deletions

View File

@ -458,7 +458,7 @@ macro_rules! fold_many0(
fold_many0!($i, |i| $submac!(i, $($args)*), $init, $fold_f)
);
($i:expr, $f:expr, $init:expr, $fold_f:expr) => (
$crate::multi::fold_many0($f, $init, $fold_f)($i)
$crate::multi::fold_many0c($i, $f, $init, $fold_f)
);
);

View File

@ -337,3 +337,13 @@ fn issue_1027_convert_error_panic_nonempty() {
"0: at line 1:\na\n ^\nexpected \'b\', got end of input\n\n"
);
}
named!(issue_962<&[u8], Vec<&[u8]>>,
fold_many0!(
alt!(tag!("aaaa") | tag!("bbbb")),
Vec::new(), |mut acc: Vec<_>, item| {
acc.push(item);
acc
}
)
);