Skip to content

Commit 481cd2d

Browse files
LoganDarkGeal
authored andcommitted
Improve rust-style identifiers code
There is no reason to heap allocate for each individual character (or each group of characters?) when the allocated collection isn't even going to be used anyway
1 parent 6892982 commit 481cd2d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/nom_recipes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ letters and numbers may be parsed like this:
115115
use nom::{
116116
IResult,
117117
branch::alt,
118-
multi::many0,
118+
multi::many0_count,
119119
combinator::recognize,
120120
sequence::pair,
121121
character::complete::{alpha1, alphanumeric1},
@@ -126,7 +126,7 @@ pub fn identifier(input: &str) -> IResult<&str, &str> {
126126
recognize(
127127
pair(
128128
alt((alpha1, tag("_"))),
129-
many0(alt((alphanumeric1, tag("_"))))
129+
many0_count(alt((alphanumeric1, tag("_"))))
130130
)
131131
)(input)
132132
}

0 commit comments

Comments
 (0)