@@ -605,9 +605,9 @@ impl<'a> Bytes<'a> {
605605 }
606606
607607 pub fn identifier ( & mut self ) -> Result < & ' a str > {
608- let next = self . peek_char_or_eof ( ) ?;
609- if !is_ident_first_char ( next ) {
610- if is_ident_raw_char ( next ) {
608+ let first = self . peek_char_or_eof ( ) ?;
609+ if !is_ident_first_char ( first ) {
610+ if is_ident_raw_char ( first ) {
611611 let ident_bytes = self . next_chars_while ( is_ident_raw_char) ;
612612 return Err ( Error :: SuggestRawIdentifier (
613613 self . string [ ..ident_bytes] . into ( ) ,
@@ -619,7 +619,7 @@ impl<'a> Bytes<'a> {
619619
620620 // If the next two bytes signify the start of a raw string literal,
621621 // return an error.
622- let length = if next == 'r' {
622+ let length = if first == 'r' {
623623 match self . bytes ( ) . get ( 1 ) . ok_or ( Error :: Eof ) ? {
624624 b'"' => return Err ( Error :: ExpectedIdentifier ) ,
625625 b'#' => {
@@ -647,10 +647,8 @@ impl<'a> Bytes<'a> {
647647 }
648648 }
649649 } else {
650- let std_ident_length = 1 + self . string
651- [ self . string . chars ( ) . next ( ) . unwrap_or_default ( ) . len_utf8 ( ) ..]
652- . find ( |c| !is_xid_continue ( c) )
653- . unwrap_or ( self . string . len ( ) - 1 ) ;
650+ let std_ident_length =
651+ first. len_utf8 ( ) + self . next_chars_while_from ( first. len_utf8 ( ) , is_xid_continue) ;
654652 let raw_ident_length = self . next_chars_while ( is_ident_raw_char) ;
655653
656654 if raw_ident_length > std_ident_length {
@@ -687,7 +685,7 @@ impl<'a> Bytes<'a> {
687685 pub fn next_chars_while_from ( & self , from : usize , condition : fn ( char ) -> bool ) -> usize {
688686 self . string [ from..]
689687 . find ( |c| !condition ( c) )
690- . unwrap_or ( self . string . len ( ) )
688+ . unwrap_or ( self . string . len ( ) - from )
691689 }
692690
693691 pub fn next_bytes_is_float ( & self ) -> bool {
@@ -721,10 +719,7 @@ impl<'a> Bytes<'a> {
721719 }
722720
723721 pub fn peek_byte_or_eof ( & self ) -> Result < u8 > {
724- self . bytes ( )
725- . first ( )
726- . copied ( )
727- . ok_or ( Error :: Eof )
722+ self . bytes ( ) . first ( ) . copied ( ) . ok_or ( Error :: Eof )
728723 }
729724
730725 pub fn peek_char_or_eof ( & self ) -> Result < char > {
@@ -879,7 +874,7 @@ impl<'a> Bytes<'a> {
879874 if byte == b'}' {
880875 break ;
881876 } else {
882- num_digits += self . advance_char ( ) ?;
877+ num_digits += self . advance_char ( ) ?;
883878 }
884879
885880 let byte = self . decode_hex ( byte) ?;
0 commit comments