[][src]Struct pahs::combinators::Alternate

#[must_use]pub struct Alternate<'pd, P: 'pd, T, E: 'pd, S, A: 'pd = ()> { /* fields omitted */ }

Try all parsers supplied via one in order and return the value of the first one that successfully parses.

If none of the parsers were successful, returns the accumulated error.

Implementations

impl<'pd, P, T, E, S, A> Alternate<'pd, P, T, E, S, A> where
    P: Pos,
    E: Recoverable,
    A: ErrorAccumulator<P, E>, 
[src]

pub fn new(driver: &'pd mut ParseDriver<S>, pos: P, err_accumulator: A) -> Self[src]

Creates a new Alternate with the specified error accumulator.

pub fn one<F>(self, parser: F) -> Self where
    F: FnOnce(&mut ParseDriver<S>, P) -> Progress<P, T, E>, 
[src]

Runs one parser if a previous one didn't parse successfully before.

pub fn finish(self) -> Progress<P, T, A::Accumulated>[src]

Completes this Alternate, returning the progress of the first successful branch.

If none of parsers were successful, it returns the accumulated errors

Panics if no parser was run via one.

Trait Implementations

impl<'pd, P: Debug + 'pd, T: Debug, E: Debug + 'pd, S: Debug, A: Debug + 'pd> Debug for Alternate<'pd, P, T, E, S, A>[src]

Auto Trait Implementations

impl<'pd, P, T, E, S, A> RefUnwindSafe for Alternate<'pd, P, T, E, S, A> where
    A: RefUnwindSafe,
    E: RefUnwindSafe,
    P: RefUnwindSafe,
    S: RefUnwindSafe,
    T: RefUnwindSafe
[src]

impl<'pd, P, T, E, S, A> Send for Alternate<'pd, P, T, E, S, A> where
    A: Send,
    E: Send,
    P: Send,
    S: Send,
    T: Send
[src]

impl<'pd, P, T, E, S, A> Sync for Alternate<'pd, P, T, E, S, A> where
    A: Sync,
    E: Sync,
    P: Sync,
    S: Sync,
    T: Sync
[src]

impl<'pd, P, T, E, S, A> Unpin for Alternate<'pd, P, T, E, S, A> where
    A: Unpin,
    E: Unpin,
    P: Unpin,
    T: Unpin
[src]

impl<'pd, P, T, E, S, A = ()> !UnwindSafe for Alternate<'pd, P, T, E, S, A>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.