shnewto / bnf

Parse BNF grammar definitions
MIT License
256 stars 22 forks source link

generic slice iterator w/ size hints #102

Closed CrockAgile closed 2 years ago

CrockAgile commented 2 years ago

This PR adds support for size hints, which closes #94

But also while working on it, I realized I had introduced a lot of bespoke iterator types with duplicate code.

Luckily Rust has generics! So this adds a new utility SliceIter generic type, reducing code 🎊

Dangers

There is one sad danger with this. It is a breaking change! The public iterator types were exposed previously (e.g. fn iter_rhs() -> CustomIter). This allows users to potentially rely on an explicit iterator type.

To prevent this in the future, return types have been updated to more opaque anonymous iterator types (e.g. fn iter_rhs() -> impl Iterator<Item = &Term>). That way, any future iterator changes should not be a breaking change.

coveralls commented 2 years ago

Coverage Status

Coverage increased (+0.5%) to 92.829% when pulling e37efa1934f89d66fa871d7623d84ba7beb82dfd on size-hints into 75356f5554885839c5feb90d28a059a3c97b83e6 on main.

shnewto commented 2 years ago

ah, I'm not at all worried about another version bump 😄 but we can also let the version bump changes collect for a minute as like an unpublished version = "0.5.0-dev" in the Cargo.toml and when we're ready to actually cut the release and publish to crates.io we make it 0.5.0

CrockAgile commented 2 years ago

sounds good to me! merge whenever then