-
-
Notifications
You must be signed in to change notification settings - Fork 355
Description
Hi all! I has been using syn for some time, and something very recurrent to me to do, is always the need to build how to access fields, like for structs do the self.#ident, specially if we are working in project when we access all fields even if they are enum or structs.
I think would be nice be able to have a field in the Field struct that represent this access, maybe something like:
pub struct Field {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
pub mutability: FieldMutability,
pub ident: Option<Ident>,
pub access_path: proc_macro2::TokenStream,
pub colon_token: Option<Colon>,
pub ty: Type,
}This would help a lot for named and unnamed structs, now to keep things simple, enums variants do not have predefined names for the fields, so use some random ones like field_x would do the trick, then we only need to declare the names in each variant Self::A#definition a function that build that from the fields would be nice, and that function would be idea to be located on the Fields struct as Option<proc_macro2::TokenStream>.
Thx!