-
Notifications
You must be signed in to change notification settings - Fork 3
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
Question: is it possible to use paren inside a prefix? #2
Comments
Hey! Glad to hear you like it :) I definitely get what you're saying with trying to avoid useless fields inside your struct - I've run into this particular case a couple times already. This currently isn't a supported feature with That being said, it's definitely possible to add and I'd be happy to look at ways to do so if there's interest. A personal concern I have about adding additional features to In terms of possible implementations if this functionality were to be added, there's multiple options. The most straightforward and flexible sort of way would be to allow the "normal" field attributes inside of Another option would be to introduce some attribute like #[derive(Parse)]
struct Findable {
#[prefix(kwd::findable)]
#[parenthesized] // <- this indicates that the rest of the prefixes AND the field itself are inside an anonymous `Paren` token
#[prefix(kwd::ty)]
#[prefix(syn::Token![=])]
ty: syn::Type,
} I think this way of doing it would be a little less clear (I've previously avoided allowing earlier attributes to change the behavior of later ones), and it also duplicates the functionality already provided for prefixes inside a token tree, but I'm open to hearing other opinions. For now, I'm currently ok with having some left-over fields in some cases - for the most part, I find it more readible, and I don't think it has too many negatives, especially because it's then less work to use those would-be-prefixed fields later! |
I hear you, you have many valid points. Maybe another option, but less clear, is to add syntax to I'll give it a shot tonight and create a pr, which you then, without hard feelings, can reject. |
This crate looks super nice! But I have a question
I'm trying to do this
It would seem logical to make it work like this
Just because I don't want useless fields inside my struct :)
The text was updated successfully, but these errors were encountered: