Skip to content

Commit

Permalink
docs: Clarify peek's behavior with Input
Browse files Browse the repository at this point in the history
Inspired by #623
  • Loading branch information
epage committed Nov 20, 2024
1 parent e8d2d3f commit 44fae65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/combinator/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ where
})
}

/// Tries to apply its parser without consuming the input.
/// Apply the parser without advancing the input.
///
/// # Example
///
Expand Down
13 changes: 12 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,18 @@ pub trait Parser<I, O, E> {

/// Take tokens from the [`Stream`], turning it into the output
///
/// This includes advancing the [`Stream`] to the next location.
/// This returns a copy of the [`Stream`] advanced to the next location.
///
/// <div class="warning">
///
/// Generally, prefer [`Parser::parse_next`].
/// This is primarily intended for:
/// - Migrating from older versions / `nom`
/// - Testing [`Parser`]s
///
/// For look-ahead parsing, see instead [`peek`][crate::combinator::peek].
///
/// </div>
#[inline(always)]
fn parse_peek(&mut self, mut input: I) -> IResult<I, O, E> {
match self.parse_next(&mut input) {
Expand Down

0 comments on commit 44fae65

Please sign in to comment.