File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,12 @@ where
225
225
"Create PartialEq implementation, if it can not be derived \
226
226
automatically.",
227
227
) ,
228
+ Arg :: new ( "with-derive-custom" )
229
+ . long ( "with-derive-custom" )
230
+ . help ( "Derive custom traits on any type." )
231
+ . value_name ( "trait" )
232
+ . multiple_occurrences ( true )
233
+ . number_of_values ( 1 ) ,
228
234
Arg :: new ( "with-derive-default" )
229
235
. long ( "with-derive-default" )
230
236
. help ( "Derive Default on any type." ) ,
@@ -744,6 +750,21 @@ where
744
750
builder = builder. impl_partialeq ( true ) ;
745
751
}
746
752
753
+ if let Some ( traits) = matches. values_of ( "with-derive-custom" ) {
754
+ #[ derive( Debug ) ]
755
+ struct CustomTraitCallback {
756
+ derives : Vec < String >
757
+ }
758
+ impl bindgen:: callbacks:: ParseCallbacks for CustomTraitCallback {
759
+ fn add_derives ( & self , _name : & str ) -> Vec < String > {
760
+ self . derives . to_owned ( )
761
+ }
762
+ }
763
+
764
+ let derives: Vec < String > = traits. into_iter ( ) . map ( |t| t. to_string ( ) ) . collect ( ) ;
765
+ builder = builder. parse_callbacks ( Box :: new ( CustomTraitCallback { derives } ) ) ;
766
+ }
767
+
747
768
if matches. is_present ( "with-derive-default" ) {
748
769
builder = builder. derive_default ( true ) ;
749
770
}
You can’t perform that action at this time.
0 commit comments