From aae761a27e39a165521da6d6371f2739228475bc Mon Sep 17 00:00:00 2001 From: Dmitry Stepanov Date: Tue, 5 May 2026 00:29:44 +0300 Subject: [PATCH] removed `ReflectBase` trait + use trait upcasting instead --- fyrox-core/src/reflect.rs | 20 +------------------- fyrox-core/src/variable.rs | 12 +++++------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/fyrox-core/src/reflect.rs b/fyrox-core/src/reflect.rs index 964de8651..7d03baca0 100644 --- a/fyrox-core/src/reflect.rs +++ b/fyrox-core/src/reflect.rs @@ -226,24 +226,6 @@ impl PartialEq for FieldMut<'_, '_> { } } -pub trait ReflectBase: Any + Debug { - fn as_any_raw(&self) -> &dyn Any; - fn as_any_raw_mut(&mut self) -> &mut dyn Any; -} - -impl ReflectBase for T -where - T: Reflect, -{ - fn as_any_raw(&self) -> &dyn Any { - self - } - - fn as_any_raw_mut(&mut self) -> &mut dyn Any { - self - } -} - /// A trait for runtime reflection. /// /// ## Code Generation @@ -299,7 +281,7 @@ where /// to string. `Display` isn't used here, because it can't be derived and it is very tedious to implement it /// for every type that should support `Reflect` trait. It is a good compromise between development speed /// and the quality of the string output. -pub trait Reflect: ReflectBase { +pub trait Reflect: Any + Debug { fn source_path() -> &'static str where Self: Sized; diff --git a/fyrox-core/src/variable.rs b/fyrox-core/src/variable.rs index 98296fd85..6034338b9 100644 --- a/fyrox-core/src/variable.rs +++ b/fyrox-core/src/variable.rs @@ -555,7 +555,7 @@ where ) -> Result>, InheritError> { let mut result: Result>, InheritError> = Ok(None); - match parent.inner_value_ref().as_any_raw().downcast_ref::() { + match (parent.inner_value_ref() as &dyn Any).downcast_ref::() { Some(parent_value) => { if !self.is_modified() { let mut parent_value_clone = parent_value.clone(); @@ -807,14 +807,14 @@ pub fn mark_inheritable_properties_modified(object: &mut dyn Reflect, ignored_ty #[cfg(test)] mod test { - use std::cell::RefCell; - use std::{cell::Cell, ops::DerefMut}; - use crate::{ reflect::{prelude::*, ReflectInheritableVariable}, variable::{try_inherit_properties, InheritableVariable, VariableFlags}, visitor::{Visit, Visitor}, }; + use std::any::Any; + use std::cell::RefCell; + use std::{cell::Cell, ops::DerefMut}; #[derive(Reflect, Clone, Debug, PartialEq)] struct Foo { @@ -1216,9 +1216,7 @@ mod test { fn inheritable_variable_ref_cell() { let v = InheritableVariable::new_modified(RefCell::new(123u32)); assert_eq!( - v.inner_value_ref() - .as_any_raw() - .downcast_ref::>(), + (v.inner_value_ref() as &dyn Any).downcast_ref::>(), Some(&RefCell::new(123u32)) ); }