Use macro-generated impls even for foreign types
kpreid opened this issue · comments
Make a macro that can be used to generate an implementation for another crate's type just like the derive macro does for a local one, and use it to implement Exhaust
for types like Option
, Result
and Ordering
.
This will ensure that our impls can have all the expected functionality and be tidily opaque rather than an aggregation of iterator combinators.
Open question: Should we rigorously use such implementations, or keep using iter::once
, iter::empty
, and such for simple cases?
Another possibility would be to wait for Rust to stabilize RFC 2515 type_alias_impl_trait
, at which point we can just use
impl Exhaust for SomeType {
type Target = impl Iterator<Item = SomeType>;
...
}
for every impl Exhaust
that isn't intending to expose its iterator type.