fn expect(
      &mut self,
      kind: TokenKind,
      error: impl FnOnce(&Token) -> ErrorKind,
   ) -> Result<Token, Error> {
      let next_token = self.lexer.peek_token()?;
      if next_token.kind == kind {
         Ok(self.lexer.next_token()?)
      } else {
         Err(self.error(&next_token, error(&next_token)))
      }
   }
/// Returns an error if the next token is not of the given kind.
Returns an error if the next token is not of the given kind.
Returns an error if the next token is not of the given kind .
fn expect(
      &mut self,
      kind: TokenKind,
      error: impl FnOnce(&Token) -> ErrorKind,
   ) -> Result<Token, Error> {
      let next_token = self.lexer.peek_token()?;
      if next_token.kind == kind {
         Ok(self.lexer.next_token()?)
      } else {
         Err(self.error(&next_token, error(&next_token)))
      }
   }
fn expect ( & mut self , kind : TokenKind , error : impl FnOnce ( & Token ) -> ErrorKind , ) -> Result < Token , Error > { let next_token = self . lexer . peek_token ( ) ? ; if next_token . kind == kind { Ok ( self . lexer . next_token ( ) ? ) } else { Err ( self . error ( & next_token , error ( & next_token ) ) ) } }
Returns an error if the next token is not of the given kind.
Returns an error if the next token is not of the given kind .
&mut self
kind
TokenKind
error
impl FnOnce(&Token) -> ErrorKind