@@ -919,14 +919,36 @@ where
919919 }
920920
921921 impl bindgen:: callbacks:: ParseCallbacks for CustomDeriveCallback {
922+ fn cli_args ( & self ) -> Vec < String > {
923+ let mut args = vec ! [ ] ;
924+
925+ let flag = match & self . kind {
926+ None => "--with-derive-custom" ,
927+ Some ( TypeKind :: Struct ) => "--with-derive-custom-struct" ,
928+ Some ( TypeKind :: Enum ) => "--with-derive-custom-enum" ,
929+ Some ( TypeKind :: Union ) => "--with-derive-custom-union" ,
930+ } ;
931+
932+ let derives = self . derives . join ( "," ) ;
933+
934+ for item in self . regex_set . get_items ( ) {
935+ args. extend_from_slice ( & [
936+ flag. to_owned ( ) ,
937+ format ! ( "{}={}" , item, derives) ,
938+ ] ) ;
939+ }
940+
941+ args
942+ }
943+
922944 fn add_derives (
923945 & self ,
924946 info : & bindgen:: callbacks:: DeriveInfo < ' _ > ,
925947 ) -> Vec < String > {
926- if self . kind . map ( |kind| kind == info. kind ) . unwrap_or ( true ) {
927- if self . regex_set . matches ( info. name ) {
928- return self . derives . clone ( ) ;
929- }
948+ if self . kind . map ( |kind| kind == info. kind ) . unwrap_or ( true )
949+ && self . regex_set . matches ( info. name )
950+ {
951+ return self . derives . clone ( ) ;
930952 }
931953 vec ! [ ]
932954 }
@@ -940,9 +962,9 @@ where
940962 ] {
941963 for custom_derive in custom_derives {
942964 let ( regex, derives) = custom_derive
943- . rsplit_once ( "=" )
965+ . rsplit_once ( '=' )
944966 . expect ( "Invalid custom derive argument: Missing `=`" ) ;
945- let derives = derives. split ( "," ) . map ( |s| s. to_owned ( ) ) . collect ( ) ;
967+ let derives = derives. split ( ',' ) . map ( |s| s. to_owned ( ) ) . collect ( ) ;
946968
947969 let mut regex_set = RegexSet :: new ( ) ;
948970 regex_set. insert ( regex) ;
0 commit comments