Function require_unambiguous

Source
pub fn require_unambiguous<'t, R>(
    text: &'t str,
    f: impl IntoIterator<Item = ParseResult<'t, R>>,
    expected: &'static str,
) -> ParseResult<'t, R>
where R: Debug,
Expand description

Used at choice points in the grammar. Iterates over all possible parses, looking for a single successful parse. If there are multiple successful parses, that indicates an ambiguous grammar, so we panic. If there are no successful parses, tries to come up with the best error it can: it prefers errors that arise from “partially successful” parses (e.g., parses that consume some input before failing), but if there are none of those, it will give an error at text saying that we expected to find a expected.