@@ -59,7 +59,7 @@ impl<'a> Cursor<'a> {
59
59
self . rest . char_indices ( )
60
60
}
61
61
62
- fn expect ( & self , tag : & str ) -> Result < Cursor < ' a > , LexError > {
62
+ fn parse ( & self , tag : & str ) -> Result < Cursor < ' a > , LexError > {
63
63
if self . starts_with ( tag) {
64
64
Ok ( self . advance ( tag. len ( ) ) )
65
65
} else {
@@ -232,7 +232,7 @@ fn group(input: Cursor) -> PResult<Group> {
232
232
let input = input. advance ( 1 ) ;
233
233
let ( input, ts) = token_stream ( input) ?;
234
234
let input = skip_whitespace ( input) ;
235
- let input = input. expect ( close) ?;
235
+ let input = input. parse ( close) ?;
236
236
Ok ( ( input, Group :: new ( delimiter, ts) ) )
237
237
}
238
238
@@ -310,9 +310,9 @@ fn literal_suffix(input: Cursor) -> Cursor {
310
310
}
311
311
312
312
fn string ( input : Cursor ) -> Result < Cursor , LexError > {
313
- if let Ok ( input) = input. expect ( "\" " ) {
313
+ if let Ok ( input) = input. parse ( "\" " ) {
314
314
cooked_string ( input)
315
- } else if let Ok ( input) = input. expect ( "r" ) {
315
+ } else if let Ok ( input) = input. parse ( "r" ) {
316
316
raw_string ( input)
317
317
} else {
318
318
Err ( LexError )
@@ -365,9 +365,9 @@ fn cooked_string(input: Cursor) -> Result<Cursor, LexError> {
365
365
}
366
366
367
367
fn byte_string ( input : Cursor ) -> Result < Cursor , LexError > {
368
- if let Ok ( input) = input. expect ( "b\" " ) {
368
+ if let Ok ( input) = input. parse ( "b\" " ) {
369
369
cooked_byte_string ( input)
370
- } else if let Ok ( input) = input. expect ( "br" ) {
370
+ } else if let Ok ( input) = input. parse ( "br" ) {
371
371
raw_string ( input)
372
372
} else {
373
373
Err ( LexError )
@@ -444,7 +444,7 @@ fn raw_string(input: Cursor) -> Result<Cursor, LexError> {
444
444
}
445
445
446
446
fn byte ( input : Cursor ) -> Result < Cursor , LexError > {
447
- let input = input. expect ( "b'" ) ?;
447
+ let input = input. parse ( "b'" ) ?;
448
448
let mut bytes = input. bytes ( ) . enumerate ( ) ;
449
449
let ok = match bytes. next ( ) . map ( |( _, b) | b) {
450
450
Some ( b'\\' ) => match bytes. next ( ) . map ( |( _, b) | b) {
@@ -462,12 +462,12 @@ fn byte(input: Cursor) -> Result<Cursor, LexError> {
462
462
if !input. chars ( ) . as_str ( ) . is_char_boundary ( offset) {
463
463
return Err ( LexError ) ;
464
464
}
465
- let input = input. advance ( offset) . expect ( "'" ) ?;
465
+ let input = input. advance ( offset) . parse ( "'" ) ?;
466
466
Ok ( literal_suffix ( input) )
467
467
}
468
468
469
469
fn character ( input : Cursor ) -> Result < Cursor , LexError > {
470
- let input = input. expect ( "'" ) ?;
470
+ let input = input. parse ( "'" ) ?;
471
471
let mut chars = input. char_indices ( ) ;
472
472
let ok = match chars. next ( ) . map ( |( _, ch) | ch) {
473
473
Some ( '\\' ) => match chars. next ( ) . map ( |( _, ch) | ch) {
@@ -484,7 +484,7 @@ fn character(input: Cursor) -> Result<Cursor, LexError> {
484
484
return Err ( LexError ) ;
485
485
}
486
486
let ( idx, _) = chars. next ( ) . ok_or ( LexError ) ?;
487
- let input = input. advance ( idx) . expect ( "'" ) ?;
487
+ let input = input. advance ( idx) . parse ( "'" ) ?;
488
488
Ok ( literal_suffix ( input) )
489
489
}
490
490
0 commit comments