Skip to content

Commit

Permalink
docs: Give example of a non-generic signature
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Feb 28, 2024
1 parent c3e3e4d commit 79d7f2b
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion src/token/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ use crate::Parser;
///
/// *Partial version*: Will return `Err(winnow::error::ErrMode::Incomplete(_))` if there's not enough input data.
///
/// # Effective Signature
///
/// Assuming you are parsing `&str`:
/// ```rust
/// # use winnow::prelude::*;;
/// pub fn any(input: &mut &str) -> PResult<char>
/// # {
/// # winnow::token::any.parse_next(input)
/// # }
/// ```
///
/// # Example
///
/// ```rust
Expand Down Expand Up @@ -85,11 +96,23 @@ where
/// **Note:** [`Parser`] is implemented for strings and byte strings as a convenience (complete
/// only)
///
/// # Effective Signature
///
/// Assuming you are parsing `&str`:
/// ```rust
/// # use winnow::prelude::*;;
/// # use winnow::error::ContextError;
/// pub fn literal(literal: &str) -> impl Parser<&str, &str, ContextError>
/// # {
/// # winnow::token::literal(literal)
/// # }
/// ```
///
/// # Example
/// ```rust
/// # use winnow::prelude::*;
/// # use winnow::{error::ErrMode, error::{InputError, ErrorKind}, error::Needed};
///
/// #
/// fn parser(s: &str) -> IResult<&str, &str> {
/// "Hello".parse_peek(s)
/// }
Expand Down Expand Up @@ -185,6 +208,19 @@ where
///
/// *Partial version*: Will return `Err(winnow::error::ErrMode::Incomplete(_))` if there's not enough input data.
///
/// # Effective Signature
///
/// Assuming you are parsing `&str`:
/// ```rust
/// # use winnow::prelude::*;;
/// # use winnow::stream::ContainsToken;
/// # use winnow::error::ContextError;
/// pub fn one_of<'i>(set: impl ContainsToken<char>) -> impl Parser<&'i str, char, ContextError>
/// # {
/// # winnow::token::one_of(set)
/// # }
/// ```
///
/// # Example
///
/// ```rust
Expand Down Expand Up @@ -242,6 +278,19 @@ where
///
/// *Partial version*: Will return `Err(winnow::error::ErrMode::Incomplete(_))` if there's not enough input data.
///
/// # Effective Signature
///
/// Assuming you are parsing `&str`:
/// ```rust
/// # use winnow::prelude::*;;
/// # use winnow::stream::ContainsToken;
/// # use winnow::error::ContextError;
/// pub fn none_of<'i>(set: impl ContainsToken<char>) -> impl Parser<&'i str, char, ContextError>
/// # {
/// # winnow::token::none_of(set)
/// # }
/// ```
///
/// # Example
///
/// ```rust
Expand Down

0 comments on commit 79d7f2b

Please sign in to comment.