Struct AndThen

Source
pub struct AndThen<P, F>(/* private fields */);

Trait Implementations§

Source§

impl<P, F, O, E> Parser for AndThen<P, F>
where P: Parser, F: FnMut(P::Output) -> Result<O, E>, E: Into<Error<<P::Input as Stream>::Item>>,

Source§

type Input = <P as Parser>::Input

A type implementing the Stream trait which is the specific type that is parsed.
Source§

type Output = O

The type which is returned when the parsing is successful.
Source§

fn parse_lazy( &mut self, input: State<<Self as Parser>::Input>, ) -> ParseResult<O, <Self as Parser>::Input, <Self::Input as Stream>::Item>

Specialized version of parse_state where the parser does not need to add an error to the ParseError when it does not consume any input before encountering the error. Instead the error can be added later through the add_error method
Source§

fn add_error(&mut self, errors: &mut ParseError<<Self::Input as Stream>::Item>)

Adds the first error that would normally be returned by this parser if it failed
Source§

fn parse( &mut self, input: Self::Input, ) -> Result<(Self::Output, Self::Input), ParseError<<Self::Input as Stream>::Item>>

Entrypoint of the parser Takes some input and tries to parse it returning a ParseResult
Source§

fn parse_state( &mut self, input: State<Self::Input>, ) -> ParseResult<Self::Output, Self::Input, <Self::Input as Stream>::Item>

Parses using the state input by calling Stream::uncons one or more times On success returns Ok((value, new_state)) on failure it returns Err(error)

Auto Trait Implementations§

§

impl<P, F> Freeze for AndThen<P, F>
where P: Freeze, F: Freeze,

§

impl<P, F> RefUnwindSafe for AndThen<P, F>

§

impl<P, F> Send for AndThen<P, F>
where P: Send, F: Send,

§

impl<P, F> Sync for AndThen<P, F>
where P: Sync, F: Sync,

§

impl<P, F> Unpin for AndThen<P, F>
where P: Unpin, F: Unpin,

§

impl<P, F> UnwindSafe for AndThen<P, F>
where P: UnwindSafe, F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P> ParserExt for P
where P: Parser,

Source§

fn with<P2>(self, p: P2) -> With<Self, P2>
where P2: Parser<Input = Self::Input>,

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

fn skip<P2>(self, p: P2) -> Skip<Self, P2>
where P2: Parser<Input = Self::Input>,

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

fn and<P2>(self, p: P2) -> And<Self, P2>
where P2: Parser<Input = Self::Input>,

Parses with self followed by p Succeds if both parsers succed, otherwise fails Returns a tuple with both values on success Read more
Source§

fn or<P2>(self, p: P2) -> Or<Self, P2>
where P2: Parser<Input = Self::Input>,

Tries to parse using self and if it fails returns the result of parsing p Read more
Source§

fn then<N, F>(self, f: F) -> Then<Self, F>
where F: FnMut(Self::Output) -> N, N: Parser<Input = Self::Input>,

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

fn map<F, B>(self, f: F) -> Map<Self, F>
where F: FnMut(Self::Output) -> B,

Uses f to map over the parsed value Read more
Source§

fn message<S>(self, msg: S) -> Message<Self>
where S: Into<Info<<Self::Input as Stream>::Item>>,

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

fn expected<S>(self, msg: S) -> Expected<Self>
where S: Into<Info<<Self::Input as Stream>::Item>>,

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
Source§

fn and_then<F, O, E>(self, f: F) -> AndThen<Self, F>
where F: FnMut(Self::Output) -> Result<O, E>, E: Into<Error<<Self::Input as Stream>::Item>>,

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
Source§

fn iter(self, input: State<Self::Input>) -> Iter<Self>

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.