-
Notifications
You must be signed in to change notification settings - Fork 732
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
Allow string literal field identifiers #2606
base: master
Are you sure you want to change the base?
Conversation
hey @valkum thanks for the code 🍻 I'm really interested in getting this into the crate, because it solves the issue of key names with @hawkw as one of the tokio members, how do you feel about the code changes in the general? |
I can see if I can rebase the current PR in the coming days. Do you want two PRs one for 0.1.x and one for master? |
Hey sorry. Nothing new. I hope I can make some progress tomorrow or next Thursday. I set myself a deadline for next weekend. |
@valkum all good 🙂 let me know, otherwise I will create a new PR branching off yours 💪 |
fa1c44d
to
a6841ce
Compare
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.
Thank you very much for the PR and sorry for the long lead time on the review.
We're happy with the change, but ideally we'd like a test for the negative case (compilation error I'm guessing) mentioned in the review comments.
Given how long it's been, if you don't have the time and/or interest to come back to this PR, please let us know and we'll hand it off to someone else.
Only a PR against master
is necessary, we'll handle backporting ourselves.
Once again, thank you very much!
I'm not entirely sure, but is this the same #2924 and #2925? This seems to be similar especially to the latter but the former seems to fix the same thing in a simpler way (unless there is a hidden issue with that approach). Arguably this has been the first PR, but I'd just like to bring it to attention here. |
It fixes the same problem but uses |
Replaces the Field.name type with an enum that can be the current Punctuated type or a LitStr
a6841ce
to
ca0c0b3
Compare
@hds Mind taking another look? |
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.
This looks good to me now, thank you!
@davidbarsky what do you think?
Any updates here? @davidbarsky @valkum we've been running our own fork for a long time waiting for this 🙏 |
Fixes #2438
Motivation
Currently, you can only use
Idents
delimited by.
for fields.This prevents us creating an empty field containing rust keywords such
as
type
. (e.g.graphql.operation.type
)The
span!
andevent!
macros allow the usage of string literals to circumventthis limitation.
Solution
To allow for a similar API as with the macros, this PR replaces the
Field.name
with an enumFieldName
.The enum can be the current
Punctuated
type or aLitStr
.Possible other solution
Another option would be to unraw the identifiers when emitting the field name. But this might cause confusion when an emitted field name does not match a struct field name in code.
I am open to providing a PR targeting the master branch as well.