Skip to content

Compatibility with VerboseError #36

@perlindgren

Description

@perlindgren

Hi fflorent and others.

Is there some example how to use nom_locate with the VerboseError type.

I tried changing the example.

fn parse_foobar(s: Span) -> IResult<Span, Token, VerboseError<&str>> {
    let (s, _) = take_until("foo")(s)?;
    let (s, pos) = position(s)?;
    let (s, foo) = tag("foo")(s)?;
    let (s, bar) = tag("baz")(s)?;

    Ok((
        s,
        Token {
            position: pos,
            foo: foo.fragment,
            bar: bar.fragment,
        },
    ))
}
fn parse_foobar(s: Span) -> IResult<Span, Token, VerboseError<&Span>> {
    let (s, _) = take_until("foo")(s)?;
    let (s, pos) = position(s)?;
    let (s, foo) = tag("foo")(s)?;
    let (s, bar) = tag("baz")(s)?; // just to trigger the error

    Ok((
        s,
        Token {
            position: pos,
            foo: foo.fragment,
            bar: bar.fragment,
        },
    ))
}

as well as:

fn parse_foobar(s: Span) -> IResult<Span, Token, VerboseError<&Span>> {
     ...
}

(The latter perhaps makes no sense...).

In both cases I end up with missing trait implementations, so I wonder if I made some stupid mistake, or that there is a compatibility issue?

(By the way, I use the latest released versions of both nom and nom_locate.)

Best regards
Per

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions