-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Cleaner macros utilizing syn::Member #18199
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
base: main
Are you sure you want to change the base?
Conversation
#[derive(QueryData)]
#[query_data(mutable(foo))]
//~^ ERROR: `mutable` does not take any arguments
struct MutableInvalidAttributeParameters {
a: &'static mut Foo,
} should we really give a error for this? seems so unnessesary and extra code. When u do this it already says "expected |
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.
Yeah, this seems cleaner!
It's a little unfortunate that syn::Member
doesn't have the rest of the Field
value, forcing most of the uses here to do fields.iter().enumerate().filter().map()
instead of just field.members()
. Would it ever make sense to add our own wrapper type around a &Field
and its index, along with a function to iterate them from a Fields
, so that we could share a little more code here?
Yeah we could do that, but would be better as a follow up pr |
Objective
Some macros were handling Idents and indexes as seperate things, we can use syn::Member to make this more readable and nicer.
Testing
ran all revelant crate tests.