Creates a checkpoint to which the token source can later return to using [`Self::rewind`].
(&self)
| 192 | |
| 193 | /// Creates a checkpoint to which the token source can later return to using [`Self::rewind`]. |
| 194 | pub(crate) fn checkpoint(&self) -> TokenSourceCheckpoint { |
| 195 | TokenSourceCheckpoint { |
| 196 | lexer_checkpoint: self.lexer.checkpoint(), |
| 197 | tokens_position: self.tokens.len(), |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /// Restore the token source to the given checkpoint. |
| 202 | pub(crate) fn rewind(&mut self, checkpoint: TokenSourceCheckpoint) { |