tidy the generated code a bit

This commit is contained in:
Joe Ardent 2023-06-13 16:15:47 -07:00
parent 46f52ff7ee
commit 62955548bb

View file

@ -19,19 +19,19 @@ pub fn derive_optional_optional_user(input: TokenStream) -> TokenStream {
}) })
.is_some(); .is_some();
let has_option = if has_user { let user_is_option_user = if has_user {
quote!( quote!(
::std::any::TypeId::of::<::std::option::Option<crate::User>>() == self.user.type_id() &&::std::any::TypeId::of::<::std::option::Option<crate::User>>() == self.user.type_id()
) )
} else { } else {
quote!(false) quote!()
}; };
let output = quote!( let output = quote!(
impl crate::templates::OptionalOptionalUser for #name { impl crate::templates::OptionalOptionalUser for #name {
fn has_optional_user(&self) -> bool { fn has_optional_user(&self) -> bool {
use ::std::any::Any; use ::std::any::Any;
#has_user && #has_option #has_user #user_is_option_user
} }
} }
); );