DanielKeep / rust-custom-derive

Custom derivation macro for Rust
Other
110 stars 17 forks source link

implement size_hint and ExactSizeIterator for IterVariant[Name]s #8

Closed durka closed 8 years ago

durka commented 8 years ago

Uses an accumulator in the macro iteration to count the variants and provide accurate (I hope...) implementations of size_hint.

Aside #1: the macros for IterVariants and IterVariantNames really ought to be unified. Aside #2: Mostly the macros take great care to use absolute paths, but there are some bare Nones in the final expansions.

cc @bluss

DanielKeep commented 8 years ago

Nice.

Aside #1: Unified as in have their implementations shares as much as possible? I agree. I've been mulling general-purpose parse_*! macros for a while, but I don't want to do that until I have a way to parse generics.

Aside #2: yeah, should probably do an audit and absolutise all the names.

durka commented 8 years ago

Parsing generics on stable without a procedural macro is a non-starter if you want to separate out the lifetimes, unless we get a back-out-able way to parse a lifetime, such as changing the parser somehow to allow ' $life:ident. If you want to parse the lifetimes and generic parameters lumped together (less useful, obviously) that should be doable.