pub trait Parser<I, O, E> {
Show 24 methods
// Required method
fn parse_next(&mut self, input: &mut I) -> PResult<O, E>;
// Provided methods
fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
where Self: Sized,
I: Stream + StreamIsPartial,
E: ParserError<I> { ... }
fn parse_peek(&mut self, input: I) -> IResult<I, O, E> { ... }
fn by_ref(&mut self) -> ByRef<'_, Self>
where Self: Sized { ... }
fn value<O2>(self, val: O2) -> Value<Self, I, O, O2, E>
where Self: Sized,
O2: Clone { ... }
fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
where Self: Sized,
O2: Default { ... }
fn void(self) -> Void<Self, I, O, E>
where Self: Sized { ... }
fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
where Self: Sized,
O: Into<O2> { ... }
fn take(self) -> Take<Self, I, O, E>
where Self: Sized,
I: Stream { ... }
fn recognize(self) -> Take<Self, I, O, E>
where Self: Sized,
I: Stream { ... }
fn with_taken(self) -> WithTaken<Self, I, O, E>
where Self: Sized,
I: Stream { ... }
fn with_recognized(self) -> WithTaken<Self, I, O, E>
where Self: Sized,
I: Stream { ... }
fn span(self) -> Span<Self, I, O, E>
where Self: Sized,
I: Stream + Location { ... }
fn with_span(self) -> WithSpan<Self, I, O, E>
where Self: Sized,
I: Stream + Location { ... }
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
where G: FnMut(O) -> O2,
Self: Sized { ... }
fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>
where Self: Sized,
G: FnMut(O) -> Result<O2, E2>,
I: Stream,
E: FromExternalError<I, E2> { ... }
fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
where Self: Sized,
G: FnMut(O) -> Option<O2>,
I: Stream,
E: ParserError<I> { ... }
fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
where Self: Sized,
G: FnMut(O) -> H,
H: Parser<I, O2, E> { ... }
fn and_then<G, O2>(self, inner: G) -> AndThen<Self, G, I, O, O2, E>
where Self: Sized,
G: Parser<O, O2, E>,
O: StreamIsPartial,
I: Stream { ... }
fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
where Self: Sized,
I: Stream,
O: ParseSlice<O2>,
E: ParserError<I> { ... }
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
where Self: Sized,
G: FnMut(&O2) -> bool,
I: Stream,
O: Borrow<O2>,
O2: ?Sized,
E: ParserError<I> { ... }
fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
where Self: Sized,
I: Stream,
E: AddContext<I, C>,
C: Clone + Debug { ... }
fn complete_err(self) -> CompleteErr<Self>
where Self: Sized { ... }
fn err_into<E2>(self) -> ErrInto<Self, I, O, E, E2>
where Self: Sized,
E: Into<E2> { ... }
}
Expand description
Core trait for parsing
The simplest way to implement a Parser
is with a function
use winnow::prelude::*;
fn empty(input: &mut &str) -> PResult<()> {
let output = ();
Ok(output)
}
let (input, output) = empty.parse_peek("Hello").unwrap();
assert_eq!(input, "Hello"); // We didn't consume any input
which can be made stateful by returning a function
use winnow::prelude::*;
fn empty<O: Clone>(output: O) -> impl FnMut(&mut &str) -> PResult<O> {
move |input: &mut &str| {
let output = output.clone();
Ok(output)
}
}
let (input, output) = empty("World").parse_peek("Hello").unwrap();
assert_eq!(input, "Hello"); // We didn't consume any input
assert_eq!(output, "World");
Additionally, some basic types implement Parser
as well, including
u8
andchar
, seewinnow::token::one_of
&[u8]
and&str
, seewinnow::token::literal
Required Methods§
Provided Methods§
Sourcefn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
Parse all of input
, generating O
from it
Sourcefn parse_peek(&mut self, input: I) -> IResult<I, O, E>
fn parse_peek(&mut self, input: I) -> IResult<I, O, E>
Sourcefn by_ref(&mut self) -> ByRef<'_, Self>where
Self: Sized,
fn by_ref(&mut self) -> ByRef<'_, Self>where
Self: Sized,
Treat &mut Self
as a parser
This helps when needing to move a Parser
when all you have is a &mut Parser
.
§Example
Because parsers are FnMut
, they can be called multiple times. This prevents moving f
into length_take
and g
into
Parser::complete_err
:
pub fn length_value<'i, O, E: ParserError<&'i [u8]>>(
mut f: impl Parser<&'i [u8], usize, E>,
mut g: impl Parser<&'i [u8], O, E>
) -> impl Parser<&'i [u8], O, E> {
move |i: &mut &'i [u8]| {
let mut data = length_take(f).parse_next(i)?;
let o = g.complete_err().parse_next(&mut data)?;
Ok(o)
}
}
By adding by_ref
, we can make this work:
pub fn length_value<'i, O, E: ParserError<&'i [u8]>>(
mut f: impl Parser<&'i [u8], usize, E>,
mut g: impl Parser<&'i [u8], O, E>
) -> impl Parser<&'i [u8], O, E> {
move |i: &mut &'i [u8]| {
let mut data = length_take(f.by_ref()).parse_next(i)?;
let o = g.by_ref().complete_err().parse_next(&mut data)?;
Ok(o)
}
}
Sourcefn value<O2>(self, val: O2) -> Value<Self, I, O, O2, E>
fn value<O2>(self, val: O2) -> Value<Self, I, O, O2, E>
Produce the provided value
§Example
use winnow::ascii::alpha1;
let mut parser = alpha1.value(1234);
assert_eq!(parser.parse_peek("abcd"), Ok(("", 1234)));
assert_eq!(parser.parse_peek("123abcd;"), Err(ErrMode::Backtrack(InputError::new("123abcd;", ErrorKind::Slice))));
Sourcefn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
Produce a type’s default value
§Example
use winnow::ascii::alpha1;
let mut parser = alpha1.default_value::<u32>();
assert_eq!(parser.parse_peek("abcd"), Ok(("", 0)));
assert_eq!(parser.parse_peek("123abcd;"), Err(ErrMode::Backtrack(InputError::new("123abcd;", ErrorKind::Slice))));
Sourcefn void(self) -> Void<Self, I, O, E>where
Self: Sized,
fn void(self) -> Void<Self, I, O, E>where
Self: Sized,
Discards the output of the Parser
§Example
use winnow::ascii::alpha1;
let mut parser = alpha1.void();
assert_eq!(parser.parse_peek("abcd"), Ok(("", ())));
assert_eq!(parser.parse_peek("123abcd;"), Err(ErrMode::Backtrack(InputError::new("123abcd;", ErrorKind::Slice))));
Sourcefn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
Convert the parser’s output to another type using std::convert::From
§Example
use winnow::ascii::alpha1;
fn parser1<'s>(i: &mut &'s str) -> PResult<&'s str, InputError<&'s str>> {
alpha1(i)
}
let mut parser2 = parser1.output_into();
// the parser converts the &str output of the child parser into a Vec<u8>
let bytes: IResult<&str, Vec<u8>> = parser2.parse_peek("abcd");
assert_eq!(bytes, Ok(("", vec![97, 98, 99, 100])));
Sourcefn take(self) -> Take<Self, I, O, E>
fn take(self) -> Take<Self, I, O, E>
Produce the consumed input as produced value.
§Example
use winnow::ascii::{alpha1};
use winnow::combinator::separated_pair;
let mut parser = separated_pair(alpha1, ',', alpha1).take();
assert_eq!(parser.parse_peek("abcd,efgh"), Ok(("", "abcd,efgh")));
assert_eq!(parser.parse_peek("abcd;"),Err(ErrMode::Backtrack(InputError::new(";", ErrorKind::Tag))));
Sourcefn recognize(self) -> Take<Self, I, O, E>
👎Deprecated since 0.6.14: Replaced with Parser::take
fn recognize(self) -> Take<Self, I, O, E>
Parser::take
Replaced with Parser::take
Sourcefn with_taken(self) -> WithTaken<Self, I, O, E>
fn with_taken(self) -> WithTaken<Self, I, O, E>
Produce the consumed input with the output
Functions similarly to take except it returns the parser output as well.
This can be useful especially in cases where the output is not the same type as the input, or the input is a user defined type.
Returned tuple is of the format (produced output, consumed input)
.
§Example
use winnow::ascii::{alpha1};
use winnow::token::literal;
use winnow::combinator::separated_pair;
fn inner_parser<'s>(input: &mut &'s str) -> PResult<bool, InputError<&'s str>> {
"1234".value(true).parse_next(input)
}
let mut consumed_parser = separated_pair(alpha1, ',', alpha1).value(true).with_taken();
assert_eq!(consumed_parser.parse_peek("abcd,efgh1"), Ok(("1", (true, "abcd,efgh"))));
assert_eq!(consumed_parser.parse_peek("abcd;"),Err(ErrMode::Backtrack(InputError::new(";", ErrorKind::Tag))));
// the second output (representing the consumed input)
// should be the same as that of the `take` parser.
let mut take_parser = inner_parser.take();
let mut consumed_parser = inner_parser.with_taken().map(|(output, consumed)| consumed);
assert_eq!(take_parser.parse_peek("1234"), consumed_parser.parse_peek("1234"));
assert_eq!(take_parser.parse_peek("abcd"), consumed_parser.parse_peek("abcd"));
Sourcefn with_recognized(self) -> WithTaken<Self, I, O, E>
👎Deprecated since 0.6.14: Replaced with Parser::with_taken
fn with_recognized(self) -> WithTaken<Self, I, O, E>
Parser::with_taken
Replaced with Parser::with_taken
Sourcefn span(self) -> Span<Self, I, O, E>
fn span(self) -> Span<Self, I, O, E>
Produce the location of the consumed input as produced value.
§Example
use winnow::stream::Located;
use winnow::ascii::alpha1;
use winnow::combinator::separated_pair;
let mut parser = separated_pair(alpha1.span(), ',', alpha1.span());
assert_eq!(parser.parse(Located::new("abcd,efgh")), Ok((0..4, 5..9)));
assert_eq!(parser.parse_peek(Located::new("abcd;")),Err(ErrMode::Backtrack(InputError::new(Located::new("abcd;").peek_slice(4).0, ErrorKind::Tag))));
Sourcefn with_span(self) -> WithSpan<Self, I, O, E>
fn with_span(self) -> WithSpan<Self, I, O, E>
Produce the location of consumed input with the output
Functions similarly to Parser::span
except it
returns the parser output as well.
This can be useful especially in cases where the output is not the same type as the input, or the input is a user defined type.
Returned tuple is of the format (produced output, consumed input)
.
§Example
use winnow::stream::Located;
use winnow::ascii::alpha1;
use winnow::token::literal;
use winnow::combinator::separated_pair;
fn inner_parser<'s>(input: &mut Located<&'s str>) -> PResult<bool, InputError<Located<&'s str>>> {
"1234".value(true).parse_next(input)
}
let mut consumed_parser = separated_pair(alpha1.value(1).with_span(), ',', alpha1.value(2).with_span());
assert_eq!(consumed_parser.parse(Located::new("abcd,efgh")), Ok(((1, 0..4), (2, 5..9))));
assert_eq!(consumed_parser.parse_peek(Located::new("abcd;")),Err(ErrMode::Backtrack(InputError::new(Located::new("abcd;").peek_slice(4).0, ErrorKind::Tag))));
// the second output (representing the consumed input)
// should be the same as that of the `span` parser.
let mut span_parser = inner_parser.span();
let mut consumed_parser = inner_parser.with_span().map(|(output, consumed)| consumed);
assert_eq!(span_parser.parse_peek(Located::new("1234")), consumed_parser.parse_peek(Located::new("1234")));
assert_eq!(span_parser.parse_peek(Located::new("abcd")), consumed_parser.parse_peek(Located::new("abcd")));
Sourcefn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
Maps a function over the output of a parser
§Example
use winnow::{error::ErrMode,error::ErrorKind, error::InputError, Parser};
use winnow::ascii::digit1;
let mut parser = digit1.map(|s: &str| s.len());
// the parser will count how many characters were returned by digit1
assert_eq!(parser.parse_peek("123456"), Ok(("", 6)));
// this will fail if digit1 fails
assert_eq!(parser.parse_peek("abc"), Err(ErrMode::Backtrack(InputError::new("abc", ErrorKind::Slice))));
Sourcefn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>
fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>
Applies a function returning a Result
over the output of a parser.
§Example
use winnow::ascii::digit1;
let mut parse = digit1.try_map(|s: &str| s.parse::<u8>());
// the parser will convert the result of digit1 to a number
assert_eq!(parse.parse_peek("123"), Ok(("", 123)));
// this will fail if digit1 fails
assert_eq!(parse.parse_peek("abc"), Err(ErrMode::Backtrack(InputError::new("abc", ErrorKind::Slice))));
// this will fail if the mapped function fails (a `u8` is too small to hold `123456`)
assert_eq!(parse.parse_peek("123456"), Err(ErrMode::Backtrack(InputError::new("123456", ErrorKind::Verify))));
Sourcefn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
Apply both Parser::verify
and Parser::map
.
§Example
use winnow::ascii::digit1;
let mut parse = digit1.verify_map(|s: &str| s.parse::<u8>().ok());
// the parser will convert the result of digit1 to a number
assert_eq!(parse.parse_peek("123"), Ok(("", 123)));
// this will fail if digit1 fails
assert_eq!(parse.parse_peek("abc"), Err(ErrMode::Backtrack(InputError::new("abc", ErrorKind::Slice))));
// this will fail if the mapped function fails (a `u8` is too small to hold `123456`)
assert_eq!(parse.parse_peek("123456"), Err(ErrMode::Backtrack(InputError::new("123456", ErrorKind::Verify))));
Sourcefn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
Creates a parser from the output of this one
§Example
use winnow::token::take;
use winnow::binary::u8;
fn length_take<'s>(input: &mut &'s [u8]) -> PResult<&'s [u8], InputError<&'s [u8]>> {
u8.flat_map(take).parse_next(input)
}
assert_eq!(length_take.parse_peek(&[2, 0, 1, 2][..]), Ok((&[2][..], &[0, 1][..])));
assert_eq!(length_take.parse_peek(&[4, 0, 1, 2][..]), Err(ErrMode::Backtrack(InputError::new(&[0, 1, 2][..], ErrorKind::Slice))));
which is the same as
use winnow::token::take;
use winnow::binary::u8;
fn length_take<'s>(input: &mut &'s [u8]) -> PResult<&'s [u8], InputError<&'s [u8]>> {
let length = u8.parse_next(input)?;
let data = take(length).parse_next(input)?;
Ok(data)
}
assert_eq!(length_take.parse_peek(&[2, 0, 1, 2][..]), Ok((&[2][..], &[0, 1][..])));
assert_eq!(length_take.parse_peek(&[4, 0, 1, 2][..]), Err(ErrMode::Backtrack(InputError::new(&[0, 1, 2][..], ErrorKind::Slice))));
Sourcefn and_then<G, O2>(self, inner: G) -> AndThen<Self, G, I, O, O2, E>
fn and_then<G, O2>(self, inner: G) -> AndThen<Self, G, I, O, O2, E>
Applies a second parser over the output of the first one
§Example
use winnow::ascii::digit1;
use winnow::token::take;
let mut digits = take(5u8).and_then(digit1);
assert_eq!(digits.parse_peek("12345"), Ok(("", "12345")));
assert_eq!(digits.parse_peek("123ab"), Ok(("", "123")));
assert_eq!(digits.parse_peek("123"), Err(ErrMode::Backtrack(InputError::new("123", ErrorKind::Slice))));
Sourcefn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
Apply std::str::FromStr
to the output of the parser
§Example
use winnow::{error::ErrMode,error::ErrorKind, error::InputError, Parser};
use winnow::ascii::digit1;
fn parser<'s>(input: &mut &'s str) -> PResult<u64, InputError<&'s str>> {
digit1.parse_to().parse_next(input)
}
// the parser will count how many characters were returned by digit1
assert_eq!(parser.parse_peek("123456"), Ok(("", 123456)));
// this will fail if digit1 fails
assert_eq!(parser.parse_peek("abc"), Err(ErrMode::Backtrack(InputError::new("abc", ErrorKind::Slice))));
Sourcefn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
Returns the output of the child parser if it satisfies a verification function.
The verification function takes as argument a reference to the output of the parser.
§Example
let mut parser = alpha1.verify(|s: &str| s.len() == 4);
assert_eq!(parser.parse_peek("abcd"), Ok(("", "abcd")));
assert_eq!(parser.parse_peek("abcde"), Err(ErrMode::Backtrack(InputError::new("abcde", ErrorKind::Verify))));
assert_eq!(parser.parse_peek("123abcd;"),Err(ErrMode::Backtrack(InputError::new("123abcd;", ErrorKind::Slice))));
Sourcefn context<C>(self, context: C) -> Context<Self, I, O, E, C>
fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
If parsing fails, add context to the error
This is used mainly to add user friendly information to errors when backtracking through a parse tree.
Sourcefn complete_err(self) -> CompleteErr<Self>where
Self: Sized,
fn complete_err(self) -> CompleteErr<Self>where
Self: Sized,
Transforms Incomplete
into Backtrack
§Example
let mut parser = take(5u8).complete_err();
assert_eq!(parser.parse_peek(Partial::new("abcdefg")), Ok((Partial::new("fg"), "abcde")));
assert_eq!(parser.parse_peek(Partial::new("abcd")), Err(ErrMode::Backtrack(InputError::new(Partial::new("abcd"), ErrorKind::Complete))));
Trait Implementations§
Source§impl<'a, I, O, E> Parser<I, O, E> for Box<dyn Parser<I, O, E> + 'a>
Available on crate feature alloc
only.
impl<'a, I, O, E> Parser<I, O, E> for Box<dyn Parser<I, O, E> + 'a>
alloc
only.Source§fn parse_next(&mut self, i: &mut I) -> PResult<O, E>
fn parse_next(&mut self, i: &mut I) -> PResult<O, E>
Source§fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
input
, generating O
from itSource§fn parse_peek(&mut self, input: I) -> IResult<I, O, E>
fn parse_peek(&mut self, input: I) -> IResult<I, O, E>
Source§fn by_ref(&mut self) -> ByRef<'_, Self>where
Self: Sized,
fn by_ref(&mut self) -> ByRef<'_, Self>where
Self: Sized,
&mut Self
as a parser Read moreSource§fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
Source§fn void(self) -> Void<Self, I, O, E>where
Self: Sized,
fn void(self) -> Void<Self, I, O, E>where
Self: Sized,
Parser
Read moreSource§fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
std::convert::From
Read moreSource§fn recognize(self) -> Take<Self, I, O, E>
fn recognize(self) -> Take<Self, I, O, E>
Parser::take
Parser::take
Source§fn with_taken(self) -> WithTaken<Self, I, O, E>
fn with_taken(self) -> WithTaken<Self, I, O, E>
Source§fn with_recognized(self) -> WithTaken<Self, I, O, E>
fn with_recognized(self) -> WithTaken<Self, I, O, E>
Parser::with_taken
Parser::with_taken
Source§fn span(self) -> Span<Self, I, O, E>
fn span(self) -> Span<Self, I, O, E>
Source§fn with_span(self) -> WithSpan<Self, I, O, E>
fn with_span(self) -> WithSpan<Self, I, O, E>
Source§fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
Source§fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>
fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>
Result
over the output of a parser. Read moreSource§fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
Source§fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
Source§fn and_then<G, O2>(self, inner: G) -> AndThen<Self, G, I, O, O2, E>
fn and_then<G, O2>(self, inner: G) -> AndThen<Self, G, I, O, O2, E>
Source§fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
std::str::FromStr
to the output of the parser Read moreSource§fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
Source§fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
Source§fn complete_err(self) -> CompleteErr<Self>where
Self: Sized,
fn complete_err(self) -> CompleteErr<Self>where
Self: Sized,
Implementations on Foreign Types§
Source§impl<'a, I, O, E> Parser<I, O, E> for Box<dyn Parser<I, O, E> + 'a>
Available on crate feature alloc
only.
impl<'a, I, O, E> Parser<I, O, E> for Box<dyn Parser<I, O, E> + 'a>
alloc
only.fn parse_next(&mut self, i: &mut I) -> PResult<O, E>
Source§impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for &'s str
impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for &'s str
This is a shortcut for literal
.
§Example
fn parser<'s>(s: &mut &'s str) -> PResult<&'s str, InputError<&'s str>> {
alt(("Hello", take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek("Hello, World!"), Ok((", World!", "Hello")));
assert_eq!(parser.parse_peek("Something"), Ok(("hing", "Somet")));
assert_eq!(parser.parse_peek("Some"), Err(ErrMode::Backtrack(InputError::new("Some", ErrorKind::Slice))));
assert_eq!(parser.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Slice))));
Source§impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for &'s [u8]
impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for &'s [u8]
This is a shortcut for literal
.
§Example
fn parser<'s>(s: &mut &'s [u8]) -> PResult<&'s [u8], InputError<&'s [u8]>> {
alt((&"Hello"[..], take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek(&b"Hello, World!"[..]), Ok((&b", World!"[..], &b"Hello"[..])));
assert_eq!(parser.parse_peek(&b"Something"[..]), Ok((&b"hing"[..], &b"Somet"[..])));
assert_eq!(parser.parse_peek(&b"Some"[..]), Err(ErrMode::Backtrack(InputError::new(&b"Some"[..], ErrorKind::Slice))));
assert_eq!(parser.parse_peek(&b""[..]), Err(ErrMode::Backtrack(InputError::new(&b""[..], ErrorKind::Slice))));
Source§impl<'s, I, E: ParserError<I>, const N: usize> Parser<I, <I as Stream>::Slice, E> for &'s [u8; N]
impl<'s, I, E: ParserError<I>, const N: usize> Parser<I, <I as Stream>::Slice, E> for &'s [u8; N]
This is a shortcut for literal
.
§Example
fn parser<'s>(s: &mut &'s [u8]) -> PResult<&'s [u8], InputError<&'s [u8]>> {
alt((b"Hello", take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek(&b"Hello, World!"[..]), Ok((&b", World!"[..], &b"Hello"[..])));
assert_eq!(parser.parse_peek(&b"Something"[..]), Ok((&b"hing"[..], &b"Somet"[..])));
assert_eq!(parser.parse_peek(&b"Some"[..]), Err(ErrMode::Backtrack(InputError::new(&b"Some"[..], ErrorKind::Slice))));
assert_eq!(parser.parse_peek(&b""[..]), Err(ErrMode::Backtrack(InputError::new(&b""[..], ErrorKind::Slice))));
Source§impl<I, E> Parser<I, char, E> for char
impl<I, E> Parser<I, char, E> for char
This is a shortcut for one_of
.
§Example
fn parser<'s>(i: &mut &'s str) -> PResult<char, InputError<&'s str>> {
'a'.parse_next(i)
}
assert_eq!(parser.parse_peek("abc"), Ok(("bc", 'a')));
assert_eq!(parser.parse_peek(" abc"), Err(ErrMode::Backtrack(InputError::new(" abc", ErrorKind::Tag))));
assert_eq!(parser.parse_peek("bc"), Err(ErrMode::Backtrack(InputError::new("bc", ErrorKind::Tag))));
assert_eq!(parser.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Tag))));
Source§impl<I, E> Parser<I, u8, E> for u8
impl<I, E> Parser<I, u8, E> for u8
This is a shortcut for one_of
.
§Example
fn parser<'s>(i: &mut &'s [u8]) -> PResult<u8, InputError<&'s [u8]>> {
b'a'.parse_next(i)
}
assert_eq!(parser.parse_peek(&b"abc"[..]), Ok((&b"bc"[..], b'a')));
assert_eq!(parser.parse_peek(&b" abc"[..]), Err(ErrMode::Backtrack(InputError::new(&b" abc"[..], ErrorKind::Tag))));
assert_eq!(parser.parse_peek(&b"bc"[..]), Err(ErrMode::Backtrack(InputError::new(&b"bc"[..], ErrorKind::Tag))));
assert_eq!(parser.parse_peek(&b""[..]), Err(ErrMode::Backtrack(InputError::new(&b""[..], ErrorKind::Tag))));
Source§impl<I: Stream, O1, E: ParserError<I>, P1> Parser<I, (O1,), E> for (P1,)where
P1: Parser<I, O1, E>,
impl<I: Stream, O1, E: ParserError<I>, P1> Parser<I, (O1,), E> for (P1,)where
P1: Parser<I, O1, E>,
Source§impl<I: Stream, O1, O2, O3, E: ParserError<I>, P1, P2, P3> Parser<I, (O1, O2, O3), E> for (P1, P2, P3)
impl<I: Stream, O1, O2, O3, E: ParserError<I>, P1, P2, P3> Parser<I, (O1, O2, O3), E> for (P1, P2, P3)
fn parse_next(&mut self, i: &mut I) -> PResult<(O1, O2, O3), E>
Source§impl<I: Stream, O1, O2, O3, O4, E: ParserError<I>, P1, P2, P3, P4> Parser<I, (O1, O2, O3, O4), E> for (P1, P2, P3, P4)
impl<I: Stream, O1, O2, O3, O4, E: ParserError<I>, P1, P2, P3, P4> Parser<I, (O1, O2, O3, O4), E> for (P1, P2, P3, P4)
fn parse_next(&mut self, i: &mut I) -> PResult<(O1, O2, O3, O4), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, E: ParserError<I>, P1, P2, P3, P4, P5> Parser<I, (O1, O2, O3, O4, O5), E> for (P1, P2, P3, P4, P5)
impl<I: Stream, O1, O2, O3, O4, O5, E: ParserError<I>, P1, P2, P3, P4, P5> Parser<I, (O1, O2, O3, O4, O5), E> for (P1, P2, P3, P4, P5)
fn parse_next(&mut self, i: &mut I) -> PResult<(O1, O2, O3, O4, O5), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, E: ParserError<I>, P1, P2, P3, P4, P5, P6> Parser<I, (O1, O2, O3, O4, O5, O6), E> for (P1, P2, P3, P4, P5, P6)
impl<I: Stream, O1, O2, O3, O4, O5, O6, E: ParserError<I>, P1, P2, P3, P4, P5, P6> Parser<I, (O1, O2, O3, O4, O5, O6), E> for (P1, P2, P3, P4, P5, P6)
fn parse_next(&mut self, i: &mut I) -> PResult<(O1, O2, O3, O4, O5, O6), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7> Parser<I, (O1, O2, O3, O4, O5, O6, O7), E> for (P1, P2, P3, P4, P5, P6, P7)
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7> Parser<I, (O1, O2, O3, O4, O5, O6, O7), E> for (P1, P2, P3, P4, P5, P6, P7)
fn parse_next(&mut self, i: &mut I) -> PResult<(O1, O2, O3, O4, O5, O6, O7), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8), E> for (P1, P2, P3, P4, P5, P6, P7, P8)
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8), E> for (P1, P2, P3, P4, P5, P6, P7, P8)
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9)
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9)
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
P18: Parser<I, O18, E>,
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
P18: Parser<I, O18, E>,
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
P18: Parser<I, O18, E>,
P19: Parser<I, O19, E>,
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
P18: Parser<I, O18, E>,
P19: Parser<I, O19, E>,
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
P18: Parser<I, O18, E>,
P19: Parser<I, O19, E>,
P20: Parser<I, O20, E>,
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
P18: Parser<I, O18, E>,
P19: Parser<I, O19, E>,
P20: Parser<I, O20, E>,
fn parse_next( &mut self, i: &mut I, ) -> PResult<(O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20), E>
Source§impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20, O21, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20, O21), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
P18: Parser<I, O18, E>,
P19: Parser<I, O19, E>,
P20: Parser<I, O20, E>,
P21: Parser<I, O21, E>,
impl<I: Stream, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20, O21, E: ParserError<I>, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21> Parser<I, (O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11, O12, O13, O14, O15, O16, O17, O18, O19, O20, O21), E> for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21)where
P1: Parser<I, O1, E>,
P2: Parser<I, O2, E>,
P3: Parser<I, O3, E>,
P4: Parser<I, O4, E>,
P5: Parser<I, O5, E>,
P6: Parser<I, O6, E>,
P7: Parser<I, O7, E>,
P8: Parser<I, O8, E>,
P9: Parser<I, O9, E>,
P10: Parser<I, O10, E>,
P11: Parser<I, O11, E>,
P12: Parser<I, O12, E>,
P13: Parser<I, O13, E>,
P14: Parser<I, O14, E>,
P15: Parser<I, O15, E>,
P16: Parser<I, O16, E>,
P17: Parser<I, O17, E>,
P18: Parser<I, O18, E>,
P19: Parser<I, O19, E>,
P20: Parser<I, O20, E>,
P21: Parser<I, O21, E>,
Implementors§
impl<'a, I, O, E, F> Parser<I, O, E> for F
impl<'p, I, O, E, P> Parser<I, O, E> for ByRef<'p, P>where
P: Parser<I, O, E>,
impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s str>
This is a shortcut for literal
.
§Example
fn parser<'s>(s: &mut &'s str) -> PResult<&'s str, InputError<&'s str>> {
alt((Caseless("hello"), take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek("Hello, World!"), Ok((", World!", "Hello")));
assert_eq!(parser.parse_peek("hello, World!"), Ok((", World!", "hello")));
assert_eq!(parser.parse_peek("HeLlo, World!"), Ok((", World!", "HeLlo")));
assert_eq!(parser.parse_peek("Something"), Ok(("hing", "Somet")));
assert_eq!(parser.parse_peek("Some"), Err(ErrMode::Backtrack(InputError::new("Some", ErrorKind::Slice))));
assert_eq!(parser.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Slice))));
impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s [u8]>
This is a shortcut for literal
.
§Example
use winnow::ascii::Caseless;
fn parser<'s>(s: &mut &'s [u8]) -> PResult<&'s [u8], InputError<&'s [u8]>> {
alt((Caseless(&"hello"[..]), take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek(&b"Hello, World!"[..]), Ok((&b", World!"[..], &b"Hello"[..])));
assert_eq!(parser.parse_peek(&b"hello, World!"[..]), Ok((&b", World!"[..], &b"hello"[..])));
assert_eq!(parser.parse_peek(&b"HeLlo, World!"[..]), Ok((&b", World!"[..], &b"HeLlo"[..])));
assert_eq!(parser.parse_peek(&b"Something"[..]), Ok((&b"hing"[..], &b"Somet"[..])));
assert_eq!(parser.parse_peek(&b"Some"[..]), Err(ErrMode::Backtrack(InputError::new(&b"Some"[..], ErrorKind::Slice))));
assert_eq!(parser.parse_peek(&b""[..]), Err(ErrMode::Backtrack(InputError::new(&b""[..], ErrorKind::Slice))));
impl<'s, I, E: ParserError<I>, const N: usize> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s [u8; N]>
This is a shortcut for literal
.
§Example
use winnow::ascii::Caseless;
fn parser<'s>(s: &mut &'s [u8]) -> PResult<&'s [u8], InputError<&'s [u8]>> {
alt((Caseless(b"hello"), take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek(&b"Hello, World!"[..]), Ok((&b", World!"[..], &b"Hello"[..])));
assert_eq!(parser.parse_peek(&b"hello, World!"[..]), Ok((&b", World!"[..], &b"hello"[..])));
assert_eq!(parser.parse_peek(&b"HeLlo, World!"[..]), Ok((&b", World!"[..], &b"HeLlo"[..])));
assert_eq!(parser.parse_peek(&b"Something"[..]), Ok((&b"hing"[..], &b"Somet"[..])));
assert_eq!(parser.parse_peek(&b"Some"[..]), Err(ErrMode::Backtrack(InputError::new(&b"Some"[..], ErrorKind::Slice))));
assert_eq!(parser.parse_peek(&b""[..]), Err(ErrMode::Backtrack(InputError::new(&b""[..], ErrorKind::Slice))));