clean up features flags and AnyValueContainer
This commit is contained in:
1 parent
74e9d5977a
commit
2dee361b60
1 file changed
+17
-12
+17
-12
@@ -8,7 +8,6 @@ use std::{
|
|||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
fmt::Arguments,
|
fmt::Arguments,
|
||||||
future::Future,
|
future::Future,
|
||||||
rc::Rc,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type TemplateId = &'static str;
|
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
|
/// A boxed value that implements PartialEq and Any
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
#[cfg(not(feature = "sync_attributes"))]
|
#[cfg(not(feature = "sync_attributes"))]
|
||||||
pub struct AnyValueContainer(pub Rc<dyn AnyValue>);
|
pub struct AnyValueContainer(pub std::rc::Rc<dyn AnyValue>);
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
#[cfg(feature = "sync_attributes")]
|
#[cfg(feature = "sync_attributes")]
|
||||||
|
/// A boxed value that implements PartialEq, Any, Sync, and Send
|
||||||
pub struct AnyValueContainer(pub std::sync::Arc<dyn AnyValue>);
|
pub struct AnyValueContainer(pub std::sync::Arc<dyn AnyValue>);
|
||||||
|
|
||||||
impl PartialEq for AnyValueContainer {
|
impl PartialEq for AnyValueContainer {
|
||||||
@@ -389,11 +389,12 @@ impl PartialEq for AnyValueContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AnyValueContainer {
|
impl AnyValueContainer {
|
||||||
|
/// Create a new AnyValueContainer containing the specified data.
|
||||||
pub fn new<T: AnyValueBounds>(value: T) -> Self {
|
pub fn new<T: AnyValueBounds>(value: T) -> Self {
|
||||||
#[cfg(feature = "sync_attributes")]
|
#[cfg(feature = "sync_attributes")]
|
||||||
return Self(std::sync::Arc::new(value));
|
return Self(std::sync::Arc::new(value));
|
||||||
#[cfg(not(feature = "sync_attributes"))]
|
#[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.
|
/// 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")]
|
#[cfg(feature = "sync_attributes")]
|
||||||
pub trait AnyValueBounds: Any + PartialEq + Sync {}
|
pub trait AnyValueBounds: Any + PartialEq + Sync + Send {}
|
||||||
|
#[cfg(feature = "sync_attributes")]
|
||||||
|
impl<T: Any + PartialEq + Send + Sync> AnyValueBounds for T {}
|
||||||
#[cfg(not(feature = "sync_attributes"))]
|
#[cfg(not(feature = "sync_attributes"))]
|
||||||
pub trait AnyValueBounds: Any + PartialEq {}
|
pub trait AnyValueBounds: Any + PartialEq {}
|
||||||
|
#[cfg(not(feature = "sync_attributes"))]
|
||||||
|
impl<T: Any + PartialEq> AnyValueBounds for T {}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[cfg(feature = "sync_attributes")]
|
#[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 any_cmp(&self, other: &dyn AnyValue) -> bool;
|
||||||
fn our_typeid(&self) -> TypeId;
|
fn our_typeid(&self) -> TypeId;
|
||||||
}
|
}
|
||||||
@@ -505,13 +517,6 @@ impl<T: AnyValueBounds> 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)]
|
#[doc(hidden)]
|
||||||
pub trait ComponentReturn<'a, A = ()> {
|
pub trait ComponentReturn<'a, A = ()> {
|
||||||
fn into_return(self, cx: &'a ScopeState) -> RenderReturn<'a>;
|
fn into_return(self, cx: &'a ScopeState) -> RenderReturn<'a>;
|
||||||
|
|||||||
Reference in new issue
Block a user