Skip to content

Suprised by error from is_not on empty result #1767

Open
@barskern

Description

I was suprised when using is_not that it errored when the resulting slice is empty, despite the fact that it finds the terminating character. I would think that it should only 'care' about finding the terminating character (similarly to take_till), and that it shouldn't enforce anything regarding the output. I assumed the following test case would hold. Is this the intended behaviour?

Prerequisites

Here are a few things you should provide to help me understand the issue:

  • Rust version : rustc 1.78.0 (9b00956e5 2024-04-29)
  • nom version : 7.1.3
  • nom compilation features used: default

Test case

#[test]
fn nom_bytes_is_not_assumption() {
    use nom::Parser;

    let input = "\n";
    let mut p = nom::bytes::complete::is_not::<_, _, nom::error::VerboseError<&str>>("\r\n\t");
    let (rem, v) = p.parse(input).unwrap();

    assert_eq!("", v);
    assert_eq!(input, rem);
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions