Document (or fix?) the fact that escaped() succeeds on empty inputs #1735
Open
Description
Combinators such as many1
explicitly state they fail if the input parser accepts empty inputs. For this reason, most parsers like is_not
fail on empty inputs.
However, escaped
immediately returns Ok
when given an empty input without even attempting to run the inner parser, which otherwise would correctly return an error, which escaped
would then correctly pass up when it detects that the error was due to empty input. I'm unsure whether this is intentional or an oversight, as a code path doing the right thing does exist, but is not triggered.
This leads to an issue where wrapping an existing parser in escaped
can change its behaviour:
Workaround in my case seems to be wrapping the escaped
in verify(..., |s: &str| !s.is_empty())
- Rust version : 1.76.0
- nom version : 7.13
- nom compilation features used: default
Metadata
Assignees
Labels
No labels