diff options
| author | HampusM <hampus@hampusmat.com> | 2026-06-09 17:36:17 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-06-09 17:36:17 +0200 |
| commit | ea95389b7fae4d75f3c8b6c465866834545ad5d9 (patch) | |
| tree | 572df17feb33c5efd27f7fac493a1351e8459e3e /engine-macros/src/reflection/struct_impl.rs | |
| parent | 62fe748a90efc35e9a5839b55b75a3db043102f1 (diff) | |
feat(engine): add offsets to reflection of enum variant fields
Diffstat (limited to 'engine-macros/src/reflection/struct_impl.rs')
| -rw-r--r-- | engine-macros/src/reflection/struct_impl.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/engine-macros/src/reflection/struct_impl.rs b/engine-macros/src/reflection/struct_impl.rs index 57e3e21..92cf00b 100644 --- a/engine-macros/src/reflection/struct_impl.rs +++ b/engine-macros/src/reflection/struct_impl.rs @@ -22,7 +22,13 @@ pub fn generate(input: syn::ItemStruct) -> proc_macro2::TokenStream &engine_crate_path, ReflectionFieldGenOptions { field_vis_override: None, - include_byte_offset: true, + gen_get_byte_offset: &|field| { + if let Some(field_ident) = &field.ident { + quote! { std::mem::offset_of!(Self, #field_ident) } + } else { + quote! { std::mem::offset_of!(Self, #field_index) } + } + }, }, ) }); |
