fn advance_token(&mut self) -> Token {
        let first_char = self.bump().unwrap();
        let token_kind = match first_char {
            // Slash, comment or block comment.
            '/' => match self.nth_char(0) {
                '/' => self.line_comment(),
                '*' => self.block_comment(),
                _ => Slash,
            },

            // Whitespace sequence.
            c if is_whitespace(c) => self.whitespace(),

            // Raw string literal or identifier.
            'r' => match (self.nth_char(0), self.nth_char(1)) {
                ('#', c1) if is_id_start(c1) => self.raw_ident(),
                ('#', _) | ('"', _) => {
                    let (n_hashes, started, terminated) = self.raw_double_quoted_string();
                    let suffix_start = self.len_consumed();
                    if terminated {
                        self.eat_literal_suffix();
                    }
                    let kind = RawStr { n_hashes, started, terminated };
                    Literal { kind, suffix_start }
                }
                _ => self.ident(),
            },

            // Byte literal, byte string literal, raw byte string literal or identifier.
            'b' => match (self.nth_char(0), self.nth_char(1)) {
                ('\'', _) => {
                    self.bump();
                    let terminated = self.single_quoted_string();
                    let suffix_start = self.len_consumed();
                    if terminated {
                        self.eat_literal_suffix();
                    }
                    let kind = Byte { terminated };
                    Literal { kind, suffix_start }
                }
                ('"', _) => {
                    self.bump();
                    let terminated = self.double_quoted_string();
                    let suffix_start = self.len_consumed();
                    if terminated {
                        self.eat_literal_suffix();
                    }
                    let kind = ByteStr { terminated };
                    Literal { kind, suffix_start }
                }
                ('r', '"') | ('r', '#') => {
                    self.bump();
                    let (n_hashes, started, terminated) = self.raw_double_quoted_string();
                    let suffix_start = self.len_consumed();
                    if terminated {
                        self.eat_literal_suffix();
                    }
                    let kind = RawByteStr { n_hashes, started, terminated };
                    Literal { kind, suffix_start }
                }
                _ => self.ident(),
            },

            // Identifier (this should be checked after other variant that can
            // start as identifier).
            c if is_id_start(c) => self.ident(),

            // Numeric literal.
            c @ '0'..='9' => {
                let literal_kind = self.number(c);
                let suffix_start = self.len_consumed();
                self.eat_literal_suffix();
                TokenKind::Literal { kind: literal_kind, suffix_start }
            }

            // One-symbol tokens.
            ';' => Semi,
            ',' => Comma,
            '.' => Dot,
            '(' => OpenParen,
            ')' => CloseParen,
            '{' => OpenBrace,
            '}' => CloseBrace,
            '[' => OpenBracket,
            ']' => CloseBracket,
            '@' => At,
            '#' => Pound,
            '~' => Tilde,
            '?' => Question,
            ':' => Colon,
            '$' => Dollar,
            '=' => Eq,
            '!' => Not,
            '<' => Lt,
            '>' => Gt,
            '-' => Minus,
            '&' => And,
            '|' => Or,
            '+' => Plus,
            '*' => Star,
            '^' => Caret,
            '%' => Percent,

            // Lifetime or character literal.
            '\'' => self.lifetime_or_char(),

            // String literal.
            '"' => {
                let terminated = self.double_quoted_string();
                let suffix_start = self.len_consumed();
                if terminated {
                    self.eat_literal_suffix();
                }
                let kind = Str { terminated };
                Literal { kind, suffix_start }
            }
            _ => Unknown,
        };
        Token::new(token_kind, self.len_consumed())
    }
/// Parses a token from the input string.
Parses a token from the input string.
Parses a token from the input string .
fn advance_token(&mut self) -> Token {
        let first_char = self.bump().unwrap();
        let token_kind = match first_char {
            // Slash, comment or block comment.
            '/' => match self.nth_char(0) {
                '/' => self.line_comment(),
                '*' => self.block_comment(),
                _ => Slash,
            },
            // Whitespace sequence.
            c if is_whitespace(c) => self.whitespace(),
            // Raw string literal or identifier.
            'r' => match (self.nth_char(0), self.nth_char(1)) {
                ('#', c1) if is_id_start(c1) => self.raw_ident(),
                ('#', _) | ('"', _) => {
                    let (n_hashes, started, terminated) = self.raw_double_quoted_string();
                    let suffix_start = self.len_consumed();
                    if terminated {
                        self.eat_literal_suffix();
                    }
                    let kind = RawStr { n_hashes, started, terminated };
                    Literal { kind, suffix_start }
                }
                _ => self.ident(),
            },
            // Byte literal, byte string literal, raw byte string literal or identifier.
            'b' => match (self.nth_char(0), self.nth_char(1)) {
                ('\'', _) => {
                    self.bump();
                    let terminated = self.single_quoted_string();
                    let suffix_start = self.len_consumed();
                    if terminated {
                        self.eat_literal_suffix();
                    }
                    let kind = Byte { terminated };
                    Literal { kind, suffix_start }
                }
                ('"', _) => {
                    self.bump();
                    let terminated = self.double_quoted_string();
                    let suffix_start = self.len_consumed();
                    if terminated {
                        self.eat_literal_suffix();
                    }
                    let kind = ByteStr { terminated };
                    Literal { kind, suffix_start }
                }
                ('r', '"') | ('r', '#') => {
                    self.bump();
                    let (n_hashes, started, terminated) = self.raw_double_quoted_string();
                    let suffix_start = self.len_consumed();
                    if terminated {
                        self.eat_literal_suffix();
                    }
                    let kind = RawByteStr { n_hashes, started, terminated };
                    Literal { kind, suffix_start }
                }
                _ => self.ident(),
            },
            // Identifier (this should be checked after other variant that can
            // start as identifier).
            c if is_id_start(c) => self.ident(),
            // Numeric literal.
            c @ '0'..='9' => {
                let literal_kind = self.number(c);
                let suffix_start = self.len_consumed();
                self.eat_literal_suffix();
                TokenKind::Literal { kind: literal_kind, suffix_start }
            }
            // One-symbol tokens.
            ';' => Semi,
            ',' => Comma,
            '.' => Dot,
            '(' => OpenParen,
            ')' => CloseParen,
            '{' => OpenBrace,
            '}' => CloseBrace,
            '[' => OpenBracket,
            ']' => CloseBracket,
            '@' => At,
            '#' => Pound,
            '~' => Tilde,
            '?' => Question,
            ':' => Colon,
            '$' => Dollar,
            '=' => Eq,
            '!' => Not,
            '<' => Lt,
            '>' => Gt,
            '-' => Minus,
            '&' => And,
            '|' => Or,
            '+' => Plus,
            '*' => Star,
            '^' => Caret,
            '%' => Percent,
            // Lifetime or character literal.
            '\'' => self.lifetime_or_char(),
            // String literal.
            '"' => {
                let terminated = self.double_quoted_string();
                let suffix_start = self.len_consumed();
                if terminated {
                    self.eat_literal_suffix();
                }
                let kind = Str { terminated };
                Literal { kind, suffix_start }
            }
            _ => Unknown,
        };
        Token::new(token_kind, self.len_consumed())
    }
fn advance_token ( & mut self ) -> Token { let first_char = self . bump ( ) . unwrap ( ) ; let token_kind = match first_char { // Slash, comment or block comment. '/' => match self . nth_char ( 0 ) { '/' => self . line_comment ( ) , '*' => self . block_comment ( ) , _ => Slash , } , // Whitespace sequence. c if is_whitespace ( c ) => self . whitespace ( ) , // Raw string literal or identifier. 'r' => match ( self . nth_char ( 0 ) , self . nth_char ( 1 ) ) { ( '#' , c1 ) if is_id_start ( c1 ) => self . raw_ident ( ) , ( '#' , _ ) | ( '"' , _ ) => { let ( n_hashes , started , terminated ) = self . raw_double_quoted_string ( ) ; let suffix_start = self . len_consumed ( ) ; if terminated { self . eat_literal_suffix ( ) ; } let kind = RawStr { n_hashes , started , terminated } ; Literal { kind , suffix_start } } _ => self . ident ( ) , } , // Byte literal, byte string literal, raw byte string literal or identifier. 'b' => match ( self . nth_char ( 0 ) , self . nth_char ( 1 ) ) { ( '\'' , _ ) => { self . bump ( ) ; let terminated = self . single_quoted_string ( ) ; let suffix_start = self . len_consumed ( ) ; if terminated { self . eat_literal_suffix ( ) ; } let kind = Byte { terminated } ; Literal { kind , suffix_start } } ( '"' , _ ) => { self . bump ( ) ; let terminated = self . double_quoted_string ( ) ; let suffix_start = self . len_consumed ( ) ; if terminated { self . eat_literal_suffix ( ) ; } let kind = ByteStr { terminated } ; Literal { kind , suffix_start } } ( 'r' , '"' ) | ( 'r' , '#' ) => { self . bump ( ) ; let ( n_hashes , started , terminated ) = self . raw_double_quoted_string ( ) ; let suffix_start = self . len_consumed ( ) ; if terminated { self . eat_literal_suffix ( ) ; } let kind = RawByteStr { n_hashes , started , terminated } ; Literal { kind , suffix_start } } _ => self . ident ( ) , } , // Identifier (this should be checked after other variant that can // start as identifier). c if is_id_start ( c ) => self . ident ( ) , // Numeric literal. c @ '0' ..= '9' => { let literal_kind = self . number ( c ) ; let suffix_start = self . len_consumed ( ) ; self . eat_literal_suffix ( ) ; TokenKind :: Literal { kind : literal_kind , suffix_start } } // One-symbol tokens. ';' => Semi , ',' => Comma , '.' => Dot , '(' => OpenParen , ')' => CloseParen , '{' => OpenBrace , '}' => CloseBrace , '[' => OpenBracket , ']' => CloseBracket , '@' => At , '#' => Pound , '~' => Tilde , '?' => Question , ':' => Colon , '$' => Dollar , '=' => Eq , '!' => Not , '<' => Lt , '>' => Gt , '-' => Minus , '&' => And , '|' => Or , '+' => Plus , '*' => Star , '^' => Caret , '%' => Percent , // Lifetime or character literal. '\'' => self . lifetime_or_char ( ) , // String literal. '"' => { let terminated = self . double_quoted_string ( ) ; let suffix_start = self . len_consumed ( ) ; if terminated { self . eat_literal_suffix ( ) ; } let kind = Str { terminated } ; Literal { kind , suffix_start } } _ => Unknown , } ; Token :: new ( token_kind , self . len_consumed ( ) ) }
Parses a token from the input string.
Parses a token from the input string .
&mut self
&mut self