From 8848cd0732a7656a2e0913e63d224618082f21df Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 17 Jun 2026 19:41:11 +0200 Subject: feat(engine-macros): improve flexibility of Reflection macro on generic types --- engine-macros/src/reflection/field.rs | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'engine-macros/src/reflection/field.rs') diff --git a/engine-macros/src/reflection/field.rs b/engine-macros/src/reflection/field.rs index 95671c3..7c50f47 100644 --- a/engine-macros/src/reflection/field.rs +++ b/engine-macros/src/reflection/field.rs @@ -6,7 +6,6 @@ pub struct ReflectionFieldGenOptions<'a> { pub field_vis_override: Option, pub gen_get_byte_offset: &'a dyn Fn(&syn::Field) -> proc_macro2::TokenStream, - pub type_reflection_optional: bool, } pub fn generate( @@ -34,11 +33,8 @@ pub fn generate( let field_reflection_vis = generate_visibility(field_vis, &engine_crate_path); - let get_type_fn_body = if options.type_reflection_optional { - gen_get_optional_type_reflection(field_type, engine_crate_path) - } else { - gen_get_mandatory_type_reflection(field_type, engine_crate_path) - }; + let get_type_fn_body = + { gen_get_optional_type_reflection(field_type, engine_crate_path) }; quote! { #engine_crate_path::reflection::Field { @@ -102,19 +98,3 @@ fn gen_get_optional_type_reflection( .field_type_reflection() } } - -fn gen_get_mandatory_type_reflection( - field_type: &syn::Type, - engine_crate_path: &syn::Path, -) -> proc_macro2::TokenStream -{ - quote! { - fn field_type_reflection() - -> &'static #engine_crate_path::reflection::Type - { - T::type_reflection() - } - - Some(field_type_reflection::<#field_type>()) - } -} -- cgit v1.2.3-18-g5258