Struct Sequence

Source
pub struct Sequence<T>(/* private fields */);
Expand description

Sequence concatenates parsers and only succeeds if all of them do. T is always a tuple in order for Sequence to implement the Parser trait. The result is a tuple of all the parser results.

Individual parsers need to have result types implementing Default.

Implementations§

Source§

impl<T> Sequence<T>

Source

pub fn new(tuple: T) -> Sequence<T>

Trait Implementations§

Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>> Parser for Sequence<(P0, P1)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.
Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>, P2: Parser<Result = impl Default>> Parser for Sequence<(P0, P1, P2)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result, <P2 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.
Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>, P2: Parser<Result = impl Default>, P3: Parser<Result = impl Default>> Parser for Sequence<(P0, P1, P2, P3)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result, <P2 as Parser>::Result, <P3 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.
Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>, P2: Parser<Result = impl Default>, P3: Parser<Result = impl Default>, P4: Parser<Result = impl Default>> Parser for Sequence<(P0, P1, P2, P3, P4)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result, <P2 as Parser>::Result, <P3 as Parser>::Result, <P4 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.
Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>, P2: Parser<Result = impl Default>, P3: Parser<Result = impl Default>, P4: Parser<Result = impl Default>, P5: Parser<Result = impl Default>> Parser for Sequence<(P0, P1, P2, P3, P4, P5)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result, <P2 as Parser>::Result, <P3 as Parser>::Result, <P4 as Parser>::Result, <P5 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.
Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>, P2: Parser<Result = impl Default>, P3: Parser<Result = impl Default>, P4: Parser<Result = impl Default>, P5: Parser<Result = impl Default>, P6: Parser<Result = impl Default>> Parser for Sequence<(P0, P1, P2, P3, P4, P5, P6)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result, <P2 as Parser>::Result, <P3 as Parser>::Result, <P4 as Parser>::Result, <P5 as Parser>::Result, <P6 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.
Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>, P2: Parser<Result = impl Default>, P3: Parser<Result = impl Default>, P4: Parser<Result = impl Default>, P5: Parser<Result = impl Default>, P6: Parser<Result = impl Default>, P7: Parser<Result = impl Default>> Parser for Sequence<(P0, P1, P2, P3, P4, P5, P6, P7)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result, <P2 as Parser>::Result, <P3 as Parser>::Result, <P4 as Parser>::Result, <P5 as Parser>::Result, <P6 as Parser>::Result, <P7 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.
Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>, P2: Parser<Result = impl Default>, P3: Parser<Result = impl Default>, P4: Parser<Result = impl Default>, P5: Parser<Result = impl Default>, P6: Parser<Result = impl Default>, P7: Parser<Result = impl Default>, P8: Parser<Result = impl Default>> Parser for Sequence<(P0, P1, P2, P3, P4, P5, P6, P7, P8)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result, <P2 as Parser>::Result, <P3 as Parser>::Result, <P4 as Parser>::Result, <P5 as Parser>::Result, <P6 as Parser>::Result, <P7 as Parser>::Result, <P8 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.
Source§

impl<P0: Parser<Result = impl Default>, P1: Parser<Result = impl Default>, P2: Parser<Result = impl Default>, P3: Parser<Result = impl Default>, P4: Parser<Result = impl Default>, P5: Parser<Result = impl Default>, P6: Parser<Result = impl Default>, P7: Parser<Result = impl Default>, P8: Parser<Result = impl Default>, P9: Parser<Result = impl Default>> Parser for Sequence<(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)>

Source§

type Result = (<P0 as Parser>::Result, <P1 as Parser>::Result, <P2 as Parser>::Result, <P3 as Parser>::Result, <P4 as Parser>::Result, <P5 as Parser>::Result, <P6 as Parser>::Result, <P7 as Parser>::Result, <P8 as Parser>::Result, <P9 as Parser>::Result)

Source§

fn parse( &mut self, st: &mut ParseState<impl Iterator<Item = char>>, ) -> ParseResult<Self::Result>

parse consumes input from st and returns a result or an error. Read more
Source§

fn apply<R2, F: Fn(Self::Result) -> ParseResult<R2>>( self, f: F, ) -> Transform<Self::Result, R2, Self, F>
where Self: Sized,

apply transforms the result of this parser using a Transform combinator.
Source§

fn then<R2, P: Parser<Result = R2>>(self, p: P) -> Then<Self, P>
where Self: Sized,

then attempts to parse input, and if it succeeds, executes parser p, only returning p’s result. This is useful for chaining parsers of which the results are not need.

Auto Trait Implementations§

§

impl<T> Freeze for Sequence<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Sequence<T>
where T: RefUnwindSafe,

§

impl<T> Send for Sequence<T>
where T: Send,

§

impl<T> Sync for Sequence<T>
where T: Sync,

§

impl<T> Unpin for Sequence<T>
where T: Unpin,

§

impl<T> UnwindSafe for Sequence<T>
where T: 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<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.