Skip to content

Commit

Permalink
Put schema value into a variable before calling apply_metadata
Browse files Browse the repository at this point in the history
This reduces size of MIR output, which should somewhat mitigate #246
  • Loading branch information
GREsau committed Nov 11, 2023
1 parent 9415fcb commit ae9544a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions schemars_derive/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ impl<'a> SchemaMetadata<'a> {
pub fn apply_to_schema(&self, schema_expr: &mut TokenStream) {
let setters = self.make_setters();
if !setters.is_empty() {
*schema_expr = quote! {
schemars::_private::apply_metadata(#schema_expr, schemars::schema::Metadata {
*schema_expr = quote! {{
let schema = #schema_expr;
schemars::_private::apply_metadata(schema, schemars::schema::Metadata {
#(#setters)*
..Default::default()
})
}
}}
}
}

Expand Down

0 comments on commit ae9544a

Please sign in to comment.