diff --git a/schemars_derive/src/schema_exprs.rs b/schemars_derive/src/schema_exprs.rs index 6efa9b8..f41e37a 100644 --- a/schemars_derive/src/schema_exprs.rs +++ b/schemars_derive/src/schema_exprs.rs @@ -581,7 +581,7 @@ fn field_default_expr(field: &Field, container_has_default: bool) -> Option quote!(<#ty>::default()), - SerdeDefault::Path(path) => quote!(|| -> #ty { #path() }()), + SerdeDefault::Path(path) => quote!({ #path() as #ty }), }; let default_expr = match field.serde_attrs.skip_serializing_if() {