Skip to content

Commit 2dd9e63

Browse files
committed
Simplify Err(LexError)=>Err(LexError) arm in parsing punct
1 parent 361088e commit 2dd9e63

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/parse.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -726,22 +726,19 @@ fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
726726
}
727727

728728
fn punct(input: Cursor) -> PResult<Punct> {
729-
match punct_char(input) {
730-
Ok((rest, '\'')) => {
731-
if ident_any(rest)?.0.starts_with("'") {
732-
Err(LexError)
733-
} else {
734-
Ok((rest, Punct::new('\'', Spacing::Joint)))
735-
}
736-
}
737-
Ok((rest, ch)) => {
738-
let kind = match punct_char(rest) {
739-
Ok(_) => Spacing::Joint,
740-
Err(LexError) => Spacing::Alone,
741-
};
742-
Ok((rest, Punct::new(ch, kind)))
729+
let (rest, ch) = punct_char(input)?;
730+
if ch == '\'' {
731+
if ident_any(rest)?.0.starts_with("'") {
732+
Err(LexError)
733+
} else {
734+
Ok((rest, Punct::new('\'', Spacing::Joint)))
743735
}
744-
Err(LexError) => Err(LexError),
736+
} else {
737+
let kind = match punct_char(rest) {
738+
Ok(_) => Spacing::Joint,
739+
Err(LexError) => Spacing::Alone,
740+
};
741+
Ok((rest, Punct::new(ch, kind)))
745742
}
746743
}
747744

0 commit comments

Comments
 (0)