pub struct PBind<P, O1, O2> { /* private fields */ }Expand description
A parser combinator that applies a transformation function to the result of a parser.
This is useful for mapping parsed values into a new representation, such as converting a parsed string into an integer, or wrapping a result in a custom enum.
§Type Parameters
P: The inner parserO1: The output type of the inner parserPO2: The output type after applying the transformation function
Trait Implementations§
Source§impl<'a, P, K, O1, O2> Parser<'a, K, O2> for PBind<P, O1, O2>
impl<'a, P, K, O1, O2> Parser<'a, K, O2> for PBind<P, O1, O2>
Source§fn then<P2, O2>(self, p2: P2) -> PSeq<Self, P2>
fn then<P2, O2>(self, p2: P2) -> PSeq<Self, P2>
Sequence two parsers and return a tuple of their results.
Source§fn or<P2>(self, p2: P2) -> POr<Self, P2>where
P2: Parser<'a, K, O>,
fn or<P2>(self, p2: P2) -> POr<Self, P2>where
P2: Parser<'a, K, O>,
Try this parser or an alternative parser if this one fails.
Source§fn map<O2, F>(self, f: F) -> PBind<Self, O, O2>
fn map<O2, F>(self, f: F) -> PBind<Self, O, O2>
Apply a function to transform the output of the parser.
Source§fn between<A, P1, P2>(self, l: P1, r: P2) -> PBetween<P1, Self, P2, A>
fn between<A, P1, P2>(self, l: P1, r: P2) -> PBetween<P1, Self, P2, A>
Apply this parser between two delimiters, discarding the delimiters’ results.
Source§fn many(self) -> PMany<Self>
fn many(self) -> PMany<Self>
Match this parser zero or more times and collect the results. This is the by
default behavior of
crate::parser::many::PMany yet one can specialize behavior
with crate::parser::many::PMany::at_least and crate::parser::many::PMany::at_mostSource§fn delimited_by<PD, A>(self, delim: PD) -> PDelim<Self, PD, A>
fn delimited_by<PD, A>(self, delim: PD) -> PDelim<Self, PD, A>
Parse this parser zero or more times separated by a delimiter (but keep only the content values).
By defualt allow trailing delimiters use
crate::parser::delim::PDelim::no_trailing,
crate::parser::delim::PDelim::at_least and crate::parser::delim::PDelim::at_most to specialize this parser.Source§fn delimited_by1<PD, A>(self, delim: PD) -> PDelim<Self, PD, A>
fn delimited_by1<PD, A>(self, delim: PD) -> PDelim<Self, PD, A>
Parse this parser one or more times separated by a delimiter (but keep only the content values).
Source§fn not(self) -> PNot<Self, O>
fn not(self) -> PNot<Self, O>
Succeeds only if this parser fails, and vice versa. Produces no value.
Source§fn padded_by<PD, A>(self, pad: PD) -> PPaddedBy<Self, PD, A>
fn padded_by<PD, A>(self, pad: PD) -> PPaddedBy<Self, PD, A>
Surround this parser with padding (like whitespace) and return the result.
Source§fn into_<Out>(self, out: Out) -> PInto<Self, O, Out, K>
fn into_<Out>(self, out: Out) -> PInto<Self, O, Out, K>
Ignores the actual parsed value and replaces it with a given one.
Source§fn debug(self, label: &'static str) -> PDebug<Self>where
K: ErrorDisplay,
fn debug(self, label: &'static str) -> PDebug<Self>where
K: ErrorDisplay,
Debug tracing combinator to help inspect parsing behavior.
Source§fn and<P2, A>(self, second: P2) -> PAnd<Self, P2, A>
fn and<P2, A>(self, second: P2) -> PAnd<Self, P2, A>
Apply another parser after this one, but return only the result of the first as well as the location after parsing.
Source§fn until_end(self) -> PUntilEnd<Self, K>
fn until_end(self) -> PUntilEnd<Self, K>
Succeeds if and only if the inner parser succeeds and consumes all input
Source§fn foldl<TP, F, I, O2>(self, tail: TP, f: F) -> PFoldLeft<Self, TP, F, I, O2>
fn foldl<TP, F, I, O2>(self, tail: TP, f: F) -> PFoldLeft<Self, TP, F, I, O2>
Use
self as init while folding left on tail using fSource§fn ignore_then<P2, OO>(self, then: P2) -> PIgnoreThen<Self, P2, O>
fn ignore_then<P2, OO>(self, then: P2) -> PIgnoreThen<Self, P2, O>
Parsers two parsers in sequence ignores the result of the first and returns the result of the second
Source§fn then_ignore<P2, OI>(self, ignore: P2) -> PThenIgnore<Self, P2, OI>
fn then_ignore<P2, OI>(self, ignore: P2) -> PThenIgnore<Self, P2, OI>
Parsers two parsers in sequence returns the result of the first and ignores the result of the second
Source§fn map_with_span<F, O2>(self, f: F) -> PMapWithSpan<Self, O, O2>
fn map_with_span<F, O2>(self, f: F) -> PMapWithSpan<Self, O, O2>
Map the result of the parser through a function with the span which the parser was successful parsing
Source§impl<'a, P, K, O1, O2> ParserCore<'a, K, O2> for PBind<P, O1, O2>
impl<'a, P, K, O1, O2> ParserCore<'a, K, O2> for PBind<P, O1, O2>
Source§fn parse(&self, i: PInput<'a, K>) -> Result<PSuccess<'a, K, O2>, Error<'a, K>>
fn parse(&self, i: PInput<'a, K>) -> Result<PSuccess<'a, K, O2>, Error<'a, K>>
Applies the inner parser, then transforms its result using the function f.
If parsing succeeds, the transformation function is applied to the result, and the transformed value is returned.
§Errors
Returns a parse failure if the inner parser p fails.
Auto Trait Implementations§
impl<P, O1, O2> Freeze for PBind<P, O1, O2>where
P: Freeze,
impl<P, O1, O2> !RefUnwindSafe for PBind<P, O1, O2>
impl<P, O1, O2> !Send for PBind<P, O1, O2>
impl<P, O1, O2> !Sync for PBind<P, O1, O2>
impl<P, O1, O2> Unpin for PBind<P, O1, O2>where
P: Unpin,
impl<P, O1, O2> !UnwindSafe for PBind<P, O1, O2>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<K> IntoToken<K> for K
impl<K> IntoToken<K> for K
Source§fn into_token(self) -> K
fn into_token(self) -> K
Converts
self into a token of type K.