Module combine::parser::combinator
source · Expand description
Various combinators which do not fit anywhere else.
Structs
Traits
Functions
- Equivalent to
p.and_then(f). - Returns a parser where
P::PartialStateis boxed. Useful as a way to avoid writing the type since it can get very large after combining a few parsers. - Returns a parser where
P::PartialStateis boxed. Useful as a way to avoid writing the type since it can get very large after combining a few parsers. attempt(p)behaves aspexcept it acts as if the parser hadn’t consumed any input ifpfails after consuming input. (alias fortry)- Constructs the parser lazily on each
parse_*call. This is similar tolazybut it allows different parsers to be returned on each call topwhile still reporting the correct errors. - Equivalent to
p.flat_map(f). - Takes a parser that outputs a string like value (
&str,String,&[u8]orVec<u8>) and parses it usingstd::str::FromStr. Errors if the output ofparseris not UTF-8 or ifFromStr::from_strreturns an error. - Constructs the parser lazily on each
parse_*call. Can be used to effectively reduce the size of deeply nested parsers as only the function producing the parser is stored. look_ahead(p)acts aspbut doesn’t consume input on success.- Equivalent to
p.map(f). - Succeeds only if
parserfails. Never consumes any input. - Creates a parser from a function which takes a function that are given the actual parser. Though convoluted this makes it possible to hide the concrete parser type without
Boxor losing the full information about the parser as is the case ofparser. - Constructs a parser which returns the tokens parsed by
parseraccumulated inF: Extend<P::Input::Item>instead ofP::Output. - tryDeprecated
try(p)behaves aspexcept it acts as if the parser hadn’t consumed any input ifpfails after consuming input.
Type Aliases
- Alias over
Opaquewhere the function can be a plain function pointer (does not need to capture any values)