pub trait Parser {
    type Output;
    type RawOutput: ParserOutput<UserType = Self::Output>;
    type Iter<'parse>: ParseIter<'parse, RawOutput = Self::RawOutput>
    where
        Self: 'parse;
    fn parse_iter<'parse>(
        &'parse self,
        context: &mut ParseContext<'parse>,
        start: usize
    ) -> Result<Self::Iter<'parse>, Reported>;
    fn parse(&self, s: &str) -> Result<Self::Output, ParseError> { ... }
    fn parse_raw(&self, s: &str) -> Result<Self::RawOutput, ParseError> { ... }
}Expand description
Trait implemented by all parsers.
This is implemented by the built-in parsers, like i32, as well as
user-defined parsers created with parser!.
To run a parser, pass some text to the parse method.
Required Associated Types§
sourcetype RawOutput: ParserOutput<UserType = Self::Output>
 
type RawOutput: ParserOutput<UserType = Self::Output>
The type this parser produces internally before converting to the output type.
Some combinators use the RawOutput to determine how types should combine.
For example, if A::RawOutput = (), then A produces no output;
and if B::RawOutput = (i32,) then B produces an integer;
SequenceParser<A, B>::RawOutput will then be (i32,), the
result of concatenating the two raw tuples, rather than ((), i32).
However, RawOutput is very often a singleton tuple, and these are
awkward for users, so we convert to the Output type before presenting a
result to the user.
Required Methods§
sourcefn parse_iter<'parse>(
    &'parse self,
    context: &mut ParseContext<'parse>,
    start: usize
) -> Result<Self::Iter<'parse>, Reported>
 
fn parse_iter<'parse>(
    &'parse self,
    context: &mut ParseContext<'parse>,
    start: usize
) -> Result<Self::Iter<'parse>, Reported>
Produce a parse iterator. This is an internal implementation detail of the parser and shouldn’t normally be called directly from application code.
Provided Methods§
sourcefn parse(&self, s: &str) -> Result<Self::Output, ParseError>
 
fn parse(&self, s: &str) -> Result<Self::Output, ParseError>
Fully parse the given source string s and return the resulting value.
This is the main way of using a Parser.
This succeeds only if this parser matches the entire input string. It’s
an error if any unmatched characters are left over at the end of s.