-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
default iterator for geo traits #427
Merged
Merged
Conversation
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
Either vscode or git or github is being very naughty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change list
Sized
bound on traitsIter
associated typeI've been trying to use my incubating version of geo-traits heavily, but I haven't used the iterator methods on them (e.g.
MultiPointTrait::points()
returning an iterator instead of manually iterating throughpoint(i)
for0..MultiPointTrait::num_points
) because I haven't been able to reliably implement iterators on all the different structs due to lifetime issues.I realized that maybe I could provide a default iterator for a generic "anything that implements this geo trait" and my proof of concept worked!
The changes to allow this are 1) removing the associated type for
Iter
, instead returning a concrete iterator struct and 2) making the trait requireSized
. So my question is: are there any practical drawbacks to these two changes? Is there ever a reason to want to override the iterator type on the associated type of the trait? I've always thought of iterators as just syntactic sugar for for loops, but not sure if that's always the case. And is there ever a use case for implementing these traits on unsized objects. My hunch to both was no, but I thought people might have ideas.