Struct mentat_parser_utils::value_and_span::OfExactly [] [src]

pub struct OfExactly<P, N>(_, _);

OfExactly and of_exactly allow us to express nested parsers naturally.

For example, vector().of_exactly(many(list())) parses a vector-of-lists, like [(1 2) (:a :b) ("test") ()].

The "outer" parser P and the "nested" parser N must be compatible: P must produce an output edn::ValueAndSpan which can itself be turned into a stream of child elements; and N must accept the resulting input Stream. This compatibility allows us to lift errors from the nested parser to the outer parser, which is part of what has made parsing &'a [edn::Value] difficult.

Trait Implementations

impl<P: Clone, N: Clone> Clone for OfExactly<P, N>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a, P, N, M, O> Parser for OfExactly<P, N> where
    P: Parser<Input = Stream<'a>, Output = M>,
    N: Parser<Input = Stream<'a>, Output = O>,
    M: 'a + Streaming<'a>, 
[src]

The type which is taken as input for the parser. The type must implement the Stream trait which allows the parser to read items from the type. Read more

The type which is returned if the parser is successful.

Parses using the stream input by calling [Stream::uncons] one or more times. Read more

Adds the first error that would normally be returned by this parser if it failed with an EmptyErr result. Read more

Entry point of the parser. Takes some input and tries to parse it. Read more

Parses using the stream input by calling [Stream::uncons] one or more times. Read more

Parses using the stream input by calling [Stream::uncons] one or more times. Read more

Borrows a parser instead of consuming it. Read more

Discards the value of the self parser and returns the value of p. Fails if any of the parsers fails. Read more

Discards the value of the p parser and returns the value of self. Fails if any of the parsers fails. Read more

Parses with self followed by p. Succeeds if both parsers succeed, otherwise fails. Returns a tuple with both values on success. Read more

Returns a parser which attempts to parse using self. If self fails without consuming any input it tries to consume the same input using p. Read more

Parses using self and then passes the value to f which returns a parser used to parse the rest of the input. Read more

Uses f to map over the parsed value. Read more

Uses f to map over the output of self. If f returns an error the parser fails. Read more

Parses with self and if it fails, adds the message msg to the error. Read more

Parses with self and if it fails without consuming any input any expected errors are replaced by msg. msg is then used in error messages as "Expected msg". Read more

Parses with self and applies f on the result if self parses successfully. f may optionally fail with an error which is automatically converted to a ParseError. Read more

Creates an iterator from a parser and a state. Can be used as an alternative to [many] when collecting directly into a FromIterator type is not desirable. Read more

Turns the parser into a trait object by putting it in a Box. Can be used to easily return parsers from functions without naming the type. Read more

Auto Trait Implementations

impl<P, N> Send for OfExactly<P, N> where
    N: Send,
    P: Send

impl<P, N> Sync for OfExactly<P, N> where
    N: Sync,
    P: Sync