-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
611: macro for delegating Geometry impl to it's inner cases r=michaelkirk a=michaelkirk - [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md). - [TODO] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users. --- Note there are some cases *not* yet covered by the macro, where the delegation isn't *quite* trivial enough (see CoordsIter). It's possible that the macro could be expanded, but my macro-fu is pretty weak and I'm trying to avoid proc_macro+syn as a dependency unless it's really worthwhile. This does clean up some code, but the higher comprehension cost might be controversial. I'd be ok with not merging this for now if people aren't excited about it. As an aside: There is a crate `enum_dispatch`, which does something similar, and I actually initially intended to use it, but I steered away for a couple reasons: 1. enum_dispatch seems intended for the cases where "I have a trait and an arbitrary subset of impls. I'd like to group that arbitrary subset of impls into a **new enum per trait**" Whereas here we're really only targeting one enum: geo-types::Geometry across many traits. 2. I'd like to avoid relying on `syn`. It's a big dependency. Our dev dependencies (rayon) and some of our features already use it (postgres), but our base feature set does not. 3. enum_dispatch (and thus `syn`) would have to be added to *both* geo and geo-types. In particular we want to keep geo-types really light. There's also a `delegate` crate with a similar macro. It's more sophisticated, but also relies on syn. I could be wrong about any of the above, but that was my understanding after trying to make it work for a while. Co-authored-by: Michael Kirk <michael.code@endoftheworl.de>
- Loading branch information
Showing
7 changed files
with
124 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters