[][src]Function ttk91::parsing::either

pub fn either<P1, P2, R1, R2, K, P, T>(
    parser1: P1,
    parser2: P2
) -> impl FnOnce(&mut P) -> Result<Either<R1, R2>, ParseError<K, T>> where
    P: Parser<T>,
    P1: Operation<P, R1, K, T>,
    P2: Operation<P, R2, K, T>,
    T: Clone

Tries both provided parsing operations and returns the result of the one that succeeds. If neither of the operations succeeds, tries to be clever about the error message that it returns.

In a case where an error is returned, this operation returns the error of the operation that made if furthest in the token stream before failing. If both operations failed at the same token, this operation joins both operations' error messages, given that they were of the ErrorKind::UnexpectedToken type.