[−][src]Struct pahs::combinators::Alternate
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]
P: Pos,
E: Recoverable,
A: ErrorAccumulator<P, E>,
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]
F: FnOnce(&mut ParseDriver<S>, P) -> Progress<P, T, E>,
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]
A: RefUnwindSafe,
E: RefUnwindSafe,
P: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
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]
A: Send,
E: Send,
P: Send,
S: Send,
T: Send,
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]
A: Sync,
E: Sync,
P: Sync,
S: Sync,
T: Sync,
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]
A: Unpin,
E: Unpin,
P: Unpin,
T: Unpin,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,