From c245f04c8cd6c3c6fe0910868039215dc8190b59 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 26 Dec 2022 08:41:37 -0600 Subject: [PATCH] make any_cmp safe --- packages/core/src/nodes.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index cc9ac2829..7432057fe 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -500,11 +500,11 @@ pub trait AnyValue: Sync + Send + 'static { #[cfg(feature = "sync_attributes")] impl AnyValue for T { fn any_cmp(&self, other: &dyn AnyValue) -> bool { - if self.type_id() != other.type_id() { + if let Some(other) = other.as_any().downcast_ref() { + self == other + } else { return false; } - - self == unsafe { &*(other as *const _ as *const T) } } fn as_any(&self) -> &dyn Any { @@ -525,11 +525,11 @@ pub trait AnyValue: 'static { #[cfg(not(feature = "sync_attributes"))] impl AnyValue for T { fn any_cmp(&self, other: &dyn AnyValue) -> bool { - if self.type_id() != other.type_id() { + if let Some(other) = other.as_any().downcast_ref() { + self == other + } else { return false; } - - self == unsafe { &*(other as *const _ as *const T) } } fn as_any(&self) -> &dyn Any {