From 0ac02cc89391f6067ab5e95f82dee67d0dd9ac7f Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Sat, 10 Dec 2022 13:24:39 -0600 Subject: [PATCH] move any bound to trait instead of implementation --- packages/core/src/nodes.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index d00825c34..3e8638a84 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -394,7 +394,7 @@ impl AnyValueRc { /// Returns a reference to the inner value. pub fn downcast_ref(&self) -> Option<&T> { - if self.0.our_typeid() == TypeId::of::() { + if self.0.type_id() == TypeId::of::() { Some(unsafe { self.downcast_ref_unchecked() }) } else { None @@ -403,7 +403,7 @@ impl AnyValueRc { /// Checks if the inner value is of type `T`. pub fn is(&self) -> bool { - self.0.our_typeid() == TypeId::of::() + self.0.type_id() == TypeId::of::() } } @@ -468,23 +468,18 @@ impl<'a> PartialEq for AttributeValue<'a> { } #[doc(hidden)] -pub trait AnyValue { +pub trait AnyValue: Any { fn any_cmp(&self, other: &dyn AnyValue) -> bool; - fn our_typeid(&self) -> TypeId; } impl AnyValue for T { fn any_cmp(&self, other: &dyn AnyValue) -> bool { - if self.type_id() != other.our_typeid() { + if self.type_id() != other.type_id() { return false; } self == unsafe { &*(other as *const _ as *const T) } } - - fn our_typeid(&self) -> TypeId { - self.type_id() - } } #[doc(hidden)]