diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 909ced495..cc1c5f907 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -8,7 +8,6 @@ use std::{ cell::{Cell, RefCell}, fmt::Arguments, future::Future, - rc::Rc, }; pub type TemplateId = &'static str; @@ -376,10 +375,11 @@ impl<'de, 'a> serde::Deserialize<'de> for ListenerCb<'a> { /// A boxed value that implements PartialEq and Any #[derive(Clone)] #[cfg(not(feature = "sync_attributes"))] -pub struct AnyValueContainer(pub Rc); +pub struct AnyValueContainer(pub std::rc::Rc); #[derive(Clone)] #[cfg(feature = "sync_attributes")] +/// A boxed value that implements PartialEq, Any, Sync, and Send pub struct AnyValueContainer(pub std::sync::Arc); impl PartialEq for AnyValueContainer { @@ -389,11 +389,12 @@ impl PartialEq for AnyValueContainer { } impl AnyValueContainer { + /// Create a new AnyValueContainer containing the specified data. pub fn new(value: T) -> Self { #[cfg(feature = "sync_attributes")] return Self(std::sync::Arc::new(value)); #[cfg(not(feature = "sync_attributes"))] - return Self(Rc::new(value)); + return Self(std::rc::Rc::new(value)); } /// Returns a reference to the inner value without checking the type. @@ -480,13 +481,24 @@ impl<'a> PartialEq for AttributeValue<'a> { } #[cfg(feature = "sync_attributes")] -pub trait AnyValueBounds: Any + PartialEq + Sync {} +pub trait AnyValueBounds: Any + PartialEq + Sync + Send {} +#[cfg(feature = "sync_attributes")] +impl AnyValueBounds for T {} #[cfg(not(feature = "sync_attributes"))] pub trait AnyValueBounds: Any + PartialEq {} +#[cfg(not(feature = "sync_attributes"))] +impl AnyValueBounds for T {} #[doc(hidden)] #[cfg(feature = "sync_attributes")] -pub trait AnyValue: Sync { +pub trait AnyValue: Sync + Send { + fn any_cmp(&self, other: &dyn AnyValue) -> bool; + fn our_typeid(&self) -> TypeId; +} + +#[doc(hidden)] +#[cfg(not(feature = "sync_attributes"))] +pub trait AnyValue { fn any_cmp(&self, other: &dyn AnyValue) -> bool; fn our_typeid(&self) -> TypeId; } @@ -505,13 +517,6 @@ impl AnyValue for T { } } -#[doc(hidden)] -#[cfg(not(feature = "sync_attributes"))] -pub trait AnyValue { - fn any_cmp(&self, other: &dyn AnyValue) -> bool; - fn our_typeid(&self) -> TypeId; -} - #[doc(hidden)] pub trait ComponentReturn<'a, A = ()> { fn into_return(self, cx: &'a ScopeState) -> RenderReturn<'a>;