nikis05 / derive-visitor

MIT License
20 stars 6 forks source link

Generalize Drive impls for collection types #4

Closed badicsalex closed 2 years ago

badicsalex commented 2 years ago

With this rewrite, basically all collection types are automatically supported without the need to write code manually.

Unfortunately this is a breaking change, because it is a conflicting trait impl if someone has already made a custom impl for their collection class with iterates over references of Drive-able items.

nikis05 commented 2 years ago

Thanks for your contribution!

This seems like a reasonable change considering the following:

  1. Crate users would still be able to implement their own collection iteration logic using #[drive(with = "...")]
  2. This crate is small so collection libraries will never provide implementations of Drive
  3. Implementing Drive on foreign collections for end users would be painful because of the orphan rule.

I will review this and hopefully merge soon.

badicsalex commented 2 years ago

I bumped the versions.

I also added Range, RangeInclusive, etc. to the std-types implementations, because that would make my life easier in my other project. Hope it's not a problem.

Thanks for being so responsive and open about these stuff.

(EDIT: it actually works with Vec too, I just forgot to enable the feature and the error was not helpful :D)