diff options
Diffstat (limited to 'engine-reflection/src/lib.rs')
| -rw-r--r-- | engine-reflection/src/lib.rs | 9 |
1 files changed, 6 insertions, 3 deletions
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<DefaultValueFn>, pub cast_dyn_any: CastDynAnyFn, - pub get_variant_reflection: fn(&dyn Any) -> Option<&'static EnumVariant>, + pub get_variant_index: fn(&dyn Any) -> Option<usize>, } impl Enum @@ -490,10 +490,13 @@ unsafe impl<T: Reflection> Reflection for Option<T> is_unit_only: false, get_default_value: || Some(|| Box::new(Option::<T>::None)), cast_dyn_any: |ptr| ptr.cast::<Self>(), - get_variant_reflection: |target| { + get_variant_index: |target| { let target = target.downcast_ref::<Self>()?; - Some(target.get_variant_reflection()) + Some(match target { + Some(_) => 0, + None => 1, + }) }, }); } |
