From 28686c9359da2c2c46d12ae8aaada14ece17246f Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 7 Jul 2026 21:43:55 +0200 Subject: feat(engine): change enum reflection get_variant_reflection fn to get_variant_index --- engine-reflection/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engine-reflection') diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs index a76abce..a31fef0 100644 --- a/engine-reflection/src/lib.rs +++ b/engine-reflection/src/lib.rs @@ -138,7 +138,7 @@ pub struct Enum pub get_default_value: fn() -> Option, pub cast_dyn_any: CastDynAnyFn, - pub get_variant_reflection: fn(&dyn Any) -> Option<&'static EnumVariant>, + pub get_variant_index: fn(&dyn Any) -> Option, } impl Enum @@ -490,10 +490,13 @@ unsafe impl Reflection for Option is_unit_only: false, get_default_value: || Some(|| Box::new(Option::::None)), cast_dyn_any: |ptr| ptr.cast::(), - get_variant_reflection: |target| { + get_variant_index: |target| { let target = target.downcast_ref::()?; - Some(target.get_variant_reflection()) + Some(match target { + Some(_) => 0, + None => 1, + }) }, }); } -- cgit v1.2.3-18-g5258