pub trait ParserExt<I: SliceLike, O, S>: Parser<I, O, S> {
// Required methods
fn map<O2>(self, f: impl FnOnce(O) -> O2 + Copy) -> impl Parser<I, O2, S>;
fn map_if<O2>(
self,
f: impl FnOnce(O) -> Option<O2> + Copy,
) -> impl Parser<I, O2, S>;
fn filter(self, f: impl FnOnce(&O) -> bool + Copy) -> impl Parser<I, O, S>;
fn bind<O2, P: Parser<I, O2, S>>(
self,
f: impl FnOnce(O) -> P + Copy,
) -> impl Parser<I, O2, S>;
fn right<O2, P: Parser<I, O2, S>>(self, p: P) -> impl Parser<I, O2, S>;
fn left<O2, P: Parser<I, O2, S>>(self, p: P) -> impl Parser<I, O, S>;
fn parse_state(
self,
input: I,
user_state: &mut S,
) -> AnpaResult<AnpaState<'_, I, S>, O>;
fn parse_state_owned(
self,
input: I,
user_state: S,
) -> AnpaResult<AnpaStateOwned<I, S>, O>;
fn debug(self, name: &'static str) -> impl Parser<I, O, S>;
}Expand description
Convenince extension functions for all parsers.
Required Methods§
Sourcefn map<O2>(self, f: impl FnOnce(O) -> O2 + Copy) -> impl Parser<I, O2, S>
fn map<O2>(self, f: impl FnOnce(O) -> O2 + Copy) -> impl Parser<I, O2, S>
Transform the result of this parser.
See crate::combinators::map
Sourcefn map_if<O2>(
self,
f: impl FnOnce(O) -> Option<O2> + Copy,
) -> impl Parser<I, O2, S>
fn map_if<O2>( self, f: impl FnOnce(O) -> Option<O2> + Copy, ) -> impl Parser<I, O2, S>
Transform the result of this parser, or fail, by returning Some or None respectively.
See crate::combinators::map_if
Sourcefn filter(self, f: impl FnOnce(&O) -> bool + Copy) -> impl Parser<I, O, S>
fn filter(self, f: impl FnOnce(&O) -> bool + Copy) -> impl Parser<I, O, S>
Accept or reject the parse based on the predicate f.
See crate::combinators::filter
Sourcefn bind<O2, P: Parser<I, O2, S>>(
self,
f: impl FnOnce(O) -> P + Copy,
) -> impl Parser<I, O2, S>
fn bind<O2, P: Parser<I, O2, S>>( self, f: impl FnOnce(O) -> P + Copy, ) -> impl Parser<I, O2, S>
Create a new parser by taking the result of the previous and returning a new parser.
See crate::combinators::bind
Sourcefn right<O2, P: Parser<I, O2, S>>(self, p: P) -> impl Parser<I, O2, S>
fn right<O2, P: Parser<I, O2, S>>(self, p: P) -> impl Parser<I, O2, S>
Combine this parser with another, while ignoring the result of the former.
See crate::combinators::right
Sourcefn left<O2, P: Parser<I, O2, S>>(self, p: P) -> impl Parser<I, O, S>
fn left<O2, P: Parser<I, O2, S>>(self, p: P) -> impl Parser<I, O, S>
Combine this parser with another, while ignoring the result of the latter.
See crate::combinators::left
Sourcefn parse_state(
self,
input: I,
user_state: &mut S,
) -> AnpaResult<AnpaState<'_, I, S>, O>
fn parse_state( self, input: I, user_state: &mut S, ) -> AnpaResult<AnpaState<'_, I, S>, O>
Perform a parse with provided user state.
See crate::core::parse_state.
Sourcefn parse_state_owned(
self,
input: I,
user_state: S,
) -> AnpaResult<AnpaStateOwned<I, S>, O>
fn parse_state_owned( self, input: I, user_state: S, ) -> AnpaResult<AnpaStateOwned<I, S>, O>
Perform a parse with provided user state. Moves ownership of the state to the parser.
See crate::core::parse_state.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".