@@ -219,24 +219,21 @@ fn token_kind(input: Cursor) -> PResult<TokenTree> {
219
219
}
220
220
221
221
fn group ( input : Cursor ) -> PResult < Group > {
222
- if let Ok ( input) = input. expect ( "(" ) {
223
- let ( input, ts) = token_stream ( input) ?;
224
- let input = skip_whitespace ( input) ;
225
- let input = input. expect ( ")" ) ?;
226
- Ok ( ( input, Group :: new ( Delimiter :: Parenthesis , ts) ) )
227
- } else if let Ok ( input) = input. expect ( "[" ) {
228
- let ( input, ts) = token_stream ( input) ?;
229
- let input = skip_whitespace ( input) ;
230
- let input = input. expect ( "]" ) ?;
231
- Ok ( ( input, Group :: new ( Delimiter :: Bracket , ts) ) )
232
- } else if let Ok ( input) = input. expect ( "{" ) {
233
- let ( input, ts) = token_stream ( input) ?;
234
- let input = skip_whitespace ( input) ;
235
- let input = input. expect ( "}" ) ?;
236
- Ok ( ( input, Group :: new ( Delimiter :: Brace , ts) ) )
222
+ let ( delimiter, close) = if input. starts_with ( "(" ) {
223
+ ( Delimiter :: Parenthesis , ")" )
224
+ } else if input. starts_with ( "[" ) {
225
+ ( Delimiter :: Bracket , "]" )
226
+ } else if input. starts_with ( "{" ) {
227
+ ( Delimiter :: Brace , "}" )
237
228
} else {
238
- Err ( LexError )
239
- }
229
+ return Err ( LexError ) ;
230
+ } ;
231
+
232
+ let input = input. advance ( 1 ) ;
233
+ let ( input, ts) = token_stream ( input) ?;
234
+ let input = skip_whitespace ( input) ;
235
+ let input = input. expect ( close) ?;
236
+ Ok ( ( input, Group :: new ( delimiter, ts) ) )
240
237
}
241
238
242
239
fn symbol ( input : Cursor ) -> PResult < TokenTree > {
0 commit comments