Get everything rendering again
This commit is contained in:
parent
5e43c332f1
commit
1a3650ef2a
4 changed files with 12 additions and 43 deletions
|
@ -157,7 +157,7 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
|
|||
})
|
||||
.collect();
|
||||
|
||||
let refinement_refined_assigments: Vec<TokenStream2> = fields
|
||||
let refinement_refined_assignments: Vec<TokenStream2> = fields
|
||||
.iter()
|
||||
.map(|field| {
|
||||
let name = &field.ident;
|
||||
|
@ -169,37 +169,14 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
} else {
|
||||
quote! {
|
||||
if let Some(value) = refinement.#name {
|
||||
self.#name = Some(value);
|
||||
if refinement.#name.is_some() {
|
||||
self.#name = refinement.#name;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let from_refinement_assigments: Vec<TokenStream2> = fields
|
||||
.iter()
|
||||
.map(|field| {
|
||||
let name = &field.ident;
|
||||
let is_refineable = is_refineable_field(field);
|
||||
let is_optional = is_optional_field(field);
|
||||
|
||||
if is_refineable {
|
||||
quote! {
|
||||
#name: value.#name.into(),
|
||||
}
|
||||
} else if is_optional {
|
||||
quote! {
|
||||
#name: value.#name.map(|v| v.into()),
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
#name: value.#name.map(|v| v.into()).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let debug_impl = if impl_debug_on_refinement {
|
||||
let refinement_field_debugs: Vec<TokenStream2> = fields
|
||||
.iter()
|
||||
|
@ -266,21 +243,11 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
|
||||
fn refined(mut self, refinement: Self::Refinement) -> Self {
|
||||
#( #refinement_refined_assigments )*
|
||||
#( #refinement_refined_assignments )*
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl #impl_generics From<#refinement_ident #ty_generics> for #ident #ty_generics
|
||||
#where_clause
|
||||
{
|
||||
fn from(value: #refinement_ident #ty_generics) -> Self {
|
||||
Self {
|
||||
#( #from_refinement_assigments )*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl #impl_generics ::core::default::Default for #refinement_ident #ty_generics
|
||||
#where_clause
|
||||
{
|
||||
|
@ -306,6 +273,7 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
|
|||
|
||||
#debug_impl
|
||||
};
|
||||
|
||||
gen.into()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue