@@ -20,6 +20,8 @@ pub struct GeneratorOptions {
2020 pub zero_copy : Option < PathList > ,
2121 /// List of `repr(packed)` structs.
2222 pub packed : Option < PathList > ,
23+ /// List of structs that should have `Default` impl skipped.
24+ pub skip_default : Option < PathList > ,
2325}
2426
2527fn path_list_to_string ( list : Option < & PathList > ) -> HashSet < String > {
@@ -40,15 +42,23 @@ impl GeneratorOptions {
4042
4143 let zero_copy = path_list_to_string ( self . zero_copy . as_ref ( ) ) ;
4244 let packed = path_list_to_string ( self . packed . as_ref ( ) ) ;
45+ let skip_default = path_list_to_string ( self . skip_default . as_ref ( ) ) ;
46+
47+ let mut all_structs: HashSet < String > = HashSet :: new ( ) ;
48+ for struct_item in [ & zero_copy, & packed, & skip_default] . into_iter ( ) . flatten ( ) {
49+ if !all_structs. contains ( struct_item) {
50+ all_structs. insert ( struct_item. clone ( ) ) ;
51+ }
52+ }
4353
4454 let mut struct_opts: BTreeMap < String , StructOpts > = BTreeMap :: new ( ) ;
45- let all_structs: HashSet < & String > = zero_copy. union ( & packed) . collect :: < HashSet < _ > > ( ) ;
46- all_structs. into_iter ( ) . for_each ( |name| {
55+ all_structs. iter ( ) . for_each ( |name| {
4756 struct_opts. insert (
4857 name. to_string ( ) ,
4958 StructOpts {
5059 zero_copy : zero_copy. contains ( name) ,
5160 packed : packed. contains ( name) ,
61+ skip_default : skip_default. contains ( name) ,
5262 } ,
5363 ) ;
5464 } ) ;
@@ -61,6 +71,7 @@ impl GeneratorOptions {
6171pub struct StructOpts {
6272 pub packed : bool ,
6373 pub zero_copy : bool ,
74+ pub skip_default : bool ,
6475}
6576
6677pub struct Generator {
0 commit comments