mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-15 09:48:53 +00:00
simplify and avoid duplication
This commit is contained in:
parent
3f74f36418
commit
bed692e50e
1 changed files with 16 additions and 21 deletions
|
@ -319,34 +319,29 @@ impl<A: AllowedOptions> SalsaStruct<A> {
|
||||||
let field_getter = field.get_name();
|
let field_getter = field.get_name();
|
||||||
let field_ty = field.ty();
|
let field_ty = field.ty();
|
||||||
|
|
||||||
|
let field_debug = quote_spanned! { field.field.span() =>
|
||||||
|
debug_struct = debug_struct.field(
|
||||||
|
#field_name_string,
|
||||||
|
&::salsa::debug::helper::SalsaDebug::<#field_ty, #db_type>::salsa_debug(
|
||||||
|
#[allow(clippy::needless_borrow)]
|
||||||
|
&self.#field_getter(_db),
|
||||||
|
_db,
|
||||||
|
_include_all_fields
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
if self.is_identity_field(field) {
|
if self.is_identity_field(field) {
|
||||||
parse_quote_spanned! {field.field.span() =>
|
quote_spanned! { field.field.span() =>
|
||||||
debug_struct = debug_struct.field(
|
#field_debug
|
||||||
#field_name_string,
|
|
||||||
&::salsa::debug::helper::SalsaDebug::<#field_ty, #db_type>::salsa_debug(
|
|
||||||
#[allow(clippy::needless_borrow)]
|
|
||||||
&self.#field_getter(_db),
|
|
||||||
_db,
|
|
||||||
_include_all_fields
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
parse_quote_spanned! {field.field.span() =>
|
quote_spanned! { field.field.span() =>
|
||||||
if _include_all_fields {
|
if _include_all_fields {
|
||||||
debug_struct = debug_struct.field(
|
#field_debug
|
||||||
#field_name_string,
|
|
||||||
&::salsa::debug::helper::SalsaDebug::<#field_ty, #db_type>::salsa_debug(
|
|
||||||
#[allow(clippy::needless_borrow)]
|
|
||||||
&self.#field_getter(_db),
|
|
||||||
_db,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.collect::<TokenStream>();
|
.collect::<TokenStream>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue