fix benchmark compilation

This commit is contained in:
Geoffroy Couprie 2021-08-09 17:39:46 +02:00
parent 18cc1d18b9
commit eec971a60d
2 changed files with 3 additions and 3 deletions

View File

@ -37,7 +37,7 @@ fn factor(input: &[u8]) -> IResult<&[u8], i64> {
// the math by folding everything
fn term(input: &[u8]) -> IResult<&[u8], i64> {
let (input, init) = factor(input)?;
fold_many0(pair(one_of("*/"), factor), init, |acc, (op, val)| {
fold_many0(pair(one_of("*/"), factor), move || init, |acc, (op, val)| {
if op == '*' {
acc * val
} else {
@ -48,7 +48,7 @@ fn term(input: &[u8]) -> IResult<&[u8], i64> {
fn expr(input: &[u8]) -> IResult<&[u8], i64> {
let (input, init) = term(input)?;
fold_many0(pair(one_of("+-"), term), init, |acc, (op, val)| {
fold_many0(pair(one_of("+-"), term), move || init, |acc, (op, val)| {
if op == '+' {
acc + val
} else {

View File

@ -87,7 +87,7 @@ fn character(input: &str) -> IResult<&str, char> {
fn string(input: &str) -> IResult<&str, String> {
delimited(
char('"'),
fold_many0(character, String::new(), |mut string, c| {
fold_many0(character, String::new, |mut string, c| {
string.push(c);
string
}),