diff --git a/fyrox-core-derive/src/script_message_payload.rs b/fyrox-core-derive/src/script_message_payload.rs index 7f2d284d8..05f888f47 100644 --- a/fyrox-core-derive/src/script_message_payload.rs +++ b/fyrox-core-derive/src/script_message_payload.rs @@ -6,13 +6,7 @@ pub(crate) fn impl_script_message_payload(ast: DeriveInput) -> TokenStream2 { let ident = &ast.ident; quote! { impl ScriptMessagePayload for #ident { - fn as_any_ref(&self) -> &dyn std::any::Any { - self - } - fn as_any_mut(&mut self) -> &mut dyn std::any::Any { - self - } } } } diff --git a/fyrox-impl/src/script/mod.rs b/fyrox-impl/src/script/mod.rs index 8cc45ca66..c35228c91 100644 --- a/fyrox-impl/src/script/mod.rs +++ b/fyrox-impl/src/script/mod.rs @@ -72,12 +72,6 @@ pub type DynamicTypeId = i64; /// } /// ``` pub trait ScriptMessagePayload: Any + Send + Debug { - /// Returns `self` as `&dyn Any` - fn as_any_ref(&self) -> &dyn Any; - - /// Returns `self` as `&dyn Any` - fn as_any_mut(&mut self) -> &mut dyn Any; - /// By default messages are dispatched by [`TypeId::of`]`::()`. /// /// If this method returns [`Some`], then the message become dynamically typed. @@ -93,12 +87,12 @@ pub trait ScriptMessagePayload: Any + Send + Debug { impl dyn ScriptMessagePayload { /// Tries to cast the payload to a particular type. pub fn downcast_ref(&self) -> Option<&T> { - self.as_any_ref().downcast_ref::() + (self as &dyn Any).downcast_ref::() } /// Tries to cast the payload to a particular type. pub fn downcast_mut(&mut self) -> Option<&mut T> { - self.as_any_mut().downcast_mut::() + (self as &mut dyn Any).downcast_mut::() } }