Expects the peeked token to be `t` and consumes it. Otherwise, leaves the token in the stream and fails with error `err`.
(&mut self, t: Token, err: E)
| 275 | /// Expects the peeked token to be `t` and consumes it. Otherwise, leaves the token in the |
| 276 | /// stream and fails with error `err`. |
| 277 | fn expect_and_consume<E: Into<String>>(&mut self, t: Token, err: E) -> Result<TokenSpan> { |
| 278 | let peeked = self.lexer.peek()?; |
| 279 | if peeked.token != t { |
| 280 | return Err(Error::Bad(peeked.pos, err.into())); |
| 281 | } |
| 282 | Ok(self.lexer.consume_peeked()) |
| 283 | } |
| 284 | |
| 285 | /// Expects the peeked token to be `t` and consumes it. Otherwise, leaves the token in the |
| 286 | /// stream and fails with error `err`, pointing at `pos` as the original location of the |
no test coverage detected