Function error_position

Source
pub fn error_position<T: Position, E>(e: &GreedyError<T, E>) -> Option<usize>
Expand description

get the deepest error position

Examples found in repository?
examples/nom7.rs (line 38)
21fn main() {
22    // VerboseError failed at
23    //   abc012:::
24    //   ^
25    let error = parser::<VerboseError<Span>>(Span::new("abc012:::"));
26    dbg!(&error);
27    match error {
28        Err(Error(e)) => assert_eq!(e.errors.first().map(|x| x.0.position()), Some(0)),
29        _ => (),
30    };
31
32    // GreedyError failed at
33    //   abc012:::
34    //         ^
35    let error = parser::<GreedyError<Span, ErrorKind>>(Span::new("abc012:::"));
36    dbg!(&error);
37    match error {
38        Err(Error(e)) => assert_eq!(error_position(&e), Some(6)),
39        _ => (),
40    };
41}