File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -412,6 +412,7 @@ impl<'a> Struct<'a> {
412412 if self . config . options . default_impl {
413413 struct_code. push ( '\n' ) ;
414414 struct_code. push_str ( & build_default_impl_fn (
415+ self . ty ,
415416 & ty. format ( & table. struct_name ) ,
416417 & fields,
417418 ) ) ;
@@ -793,14 +794,19 @@ fn default_for_type(typ: &str) -> &'static str {
793794}
794795
795796/// Generate default (insides of the `impl Default for StructName { fn default() -> Self {} }`)
796- fn build_default_impl_fn < ' a > ( struct_name : & str , fields : & [ StructField ] ) -> String {
797+ fn build_default_impl_fn < ' a > (
798+ struct_type : StructType ,
799+ struct_name : & str ,
800+ fields : & [ StructField ] ,
801+ ) -> String {
797802 let fields: Vec < String > = fields
798803 . iter ( )
799804 . map ( |name_typ_nullable| {
800805 format ! (
801806 "{name}: {typ_default}," ,
802807 name = name_typ_nullable. name,
803- typ_default = if name_typ_nullable. is_optional {
808+ typ_default = if name_typ_nullable. is_optional || struct_type == StructType :: Update
809+ {
804810 "None"
805811 } else {
806812 default_for_type( & name_typ_nullable. base_type)
You can’t perform that action at this time.
0 commit comments