mirror of
https://gitee.com/openharmony/third_party_rust_nom
synced 2024-11-23 07:29:54 +00:00
fix benchmark compilation
This commit is contained in:
parent
18cc1d18b9
commit
eec971a60d
@ -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 {
|
||||
|
@ -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
|
||||
}),
|
||||
|
Loading…
Reference in New Issue
Block a user