Skip to content

Commit

Permalink
Document rewind
Browse files Browse the repository at this point in the history
  • Loading branch information
brunojppb committed May 30, 2024
1 parent 2d803aa commit b005685
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions md_parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,15 @@ impl<'source> Parser<'source> {
return self.previous();
}

/// Walk back the given number of steps,
/// but never move to a negative position
fn step_back(&mut self, num_steps: usize) -> Option<&(Token<'source>, Span)> {
self.current = max(0, self.current - num_steps);
return self.peek();
}

/// Jump straight to an specific position
/// with no bounds validation
fn rewind(&mut self, to_position: usize) {
self.current = to_position;
}
Expand Down

0 comments on commit b005685

Please sign in to comment.