fn consume_token(&mut self, kind: TokenKind) -> io::Result<Option<String>> {
        if self.token.kind == kind {
            if kind == TokenKind::Identifier {
                // Get underlying value for identifier
                let identifier = self.token.value.clone();
                self.token = self.tokenizer.next_token()?;
                Ok(identifier)
            } else {
                self.token = self.tokenizer.next_token()?;
                Ok(None)
            }
        } else {
            Err(Error::new(
                ErrorKind::InvalidInput,
                format!("expected {}, got {}", kind, self.token.kind),
            ))
        }
    }
/// Consume the current token if its kind matches the passed one.
Consume the current token if its kind matches the passed one.
Consume the current token if its kind matches the passed one .
fn consume_token(&mut self, kind: TokenKind) -> io::Result<Option<String>> {
        if self.token.kind == kind {
            if kind == TokenKind::Identifier {
                // Get underlying value for identifier
                let identifier = self.token.value.clone();
                self.token = self.tokenizer.next_token()?;
                Ok(identifier)
            } else {
                self.token = self.tokenizer.next_token()?;
                Ok(None)
            }
        } else {
            Err(Error::new(
                ErrorKind::InvalidInput,
                format!("expected {}, got {}", kind, self.token.kind),
            ))
        }
    }
fn consume_token ( & mut self , kind : TokenKind ) -> io :: Result < Option < String > > { if self . token . kind == kind { if kind == TokenKind :: Identifier { // Get underlying value for identifier let identifier = self . token . value . clone ( ) ; self . token = self . tokenizer . next_token ( ) ? ; Ok ( identifier ) } else { self . token = self . tokenizer . next_token ( ) ? ; Ok ( None ) } } else { Err ( Error :: new ( ErrorKind :: InvalidInput , format ! ( " " kind self token kind ) , ) ) } }
Consume the current token if its kind matches the passed one.
Consume the current token if its kind matches the passed one .
&mut self
kind
TokenKind
&mut self
kind
TokenKind