File tree 4 files changed +34
-1
lines changed
4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change
1
+ struct S {
2
+ /// <div rustbindgen attribute="#[Attr1] #[Attr2]" attribute="#[Attr3(value)]"></div>
3
+ int field_1 ;
4
+ char field_2 ;
5
+ };
Original file line number Diff line number Diff line change @@ -1567,19 +1567,29 @@ impl FieldCodegen<'_> for FieldData {
1567
1567
let accessor_kind =
1568
1568
self . annotations ( ) . accessor_kind ( ) . unwrap_or ( accessor_kind) ;
1569
1569
1570
+ let attributes: Vec < proc_macro2:: TokenStream > = self
1571
+ . annotations ( )
1572
+ . attributes ( )
1573
+ . iter ( )
1574
+ . map ( |s| s. parse ( ) . unwrap ( ) )
1575
+ . collect :: < Vec < _ > > ( ) ;
1576
+
1570
1577
match visibility {
1571
1578
FieldVisibilityKind :: Private => {
1572
1579
field. append_all ( quote ! {
1580
+ #( #attributes ) *
1573
1581
#field_ident : #ty ,
1574
1582
} ) ;
1575
1583
}
1576
1584
FieldVisibilityKind :: PublicCrate => {
1577
1585
field. append_all ( quote ! {
1586
+ #( #attributes ) *
1578
1587
pub ( crate ) #field_ident : #ty ,
1579
1588
} ) ;
1580
1589
}
1581
1590
FieldVisibilityKind :: Public => {
1582
1591
field. append_all ( quote ! {
1592
+ #( #attributes ) *
1583
1593
pub #field_ident : #ty ,
1584
1594
} ) ;
1585
1595
}
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ pub(crate) struct Annotations {
102
102
constify_enum_variant : bool ,
103
103
/// List of explicit derives for this type.
104
104
derives : Vec < String > ,
105
- /// List of explicit attributes for this type.
105
+ /// List of explicit attributes for this type/field .
106
106
attributes : Vec < String > ,
107
107
}
108
108
You can’t perform that action at this time.
0 commit comments