-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
Add Fields::iter and IntoIterator for &Fields #324
Conversation
These methods were removed in syn 0.12. They seem like an odd removal, since they're pretty widely used in the wild. This adds these methods back. Though `Fields` is the closest structurally to `VariantData`, I've opted to put it on `DataStruct` instead, as it's in the location most people will look for it. `fields.fields()` also reads really poorly. Fixes dtolnay#316
Thanks!
|
Not on stable. An empty Punctuated would require
How would you feel about putting that method on |
This can't be done unless we have a |
Is there a use case for |
I definitely had one at the time I wrote that PR (or I wouldn't have written it), but clearly I didn't go with that implementation. I don't have one off the top of my head. I personally think it's worth having for parity with |
I would drop the mut one for now if nobody will use it. What do you think of adding IntoIterator for &Fields instead of a fields() method? I think |
I can do that. I do think it's worth continuing to have the explicit |
Seems reasonable. Let's do Fields::iter and IntoIterator for &Fields. |
There you go. :) |
I just figured out how to get rid of |
While we can't easily have an empty `Punctuated` with static storage, since `punctuated::Iter` is just `slice::Iter`, we can absolutely create an empty one of those.
This should be good to go if CI agrees |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sgrif Thanks for getting rid of MaybeEmpty
:-). Definitely a cleaner API now.
VariantData::fields
and VariantData::fields_mut
These methods were removed in syn 0.12. They seem like an odd removal,
since they're pretty widely used in the wild. This adds these methods
back. Though
Fields
is the closest structurally toVariantData
, I'veopted to put it on
DataStruct
instead, as it's in the location mostpeople will look for it.
fields.fields()
also reads really poorly.Fixes #316