Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow () to be used as error type for nom::bits::{bits,bytes} #1583

Merged
merged 2 commits into from Dec 30, 2022

Conversation

cky
Copy link
Contributor

@cky cky commented Dec 9, 2022

For most parsers, you can use the unit type as the error type, which is useful if you don't actually care about the details of a parse error, only that it's failed.

However, when using nom::bits::bits and nom::bits::bytes, two error types are required: one for byte-based errors, and one for bit-based errors. Further, the error type has to conform to ErrorConvert, to allow bit-based errors to be converted to byte-based errors (for nom::bits::bits) and vice versa (for nom::bits::bytes).

This branch makes the unit type conform to ErrorConvert with a trivial implementation, to enable it to be used as both error types for nom::bits::bits and nom::bits::bytes.

@Geal Geal self-requested a review as a code owner December 30, 2022 15:31
@coveralls
Copy link

Pull Request Test Coverage Report for Build 3807683872

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 61.963%

Files with Coverage Reduction New Missed Lines %
src/traits.rs 5 62.63%
Totals Coverage Status
Change from base Build 3807681115: 0.02%
Covered Lines: 1515
Relevant Lines: 2445

💛 - Coveralls

@Geal Geal merged commit 3c5e08c into rust-bakery:main Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants