Make EventHandler copy (#2112)

* implement Copy for EventHandler
* implement from closure for event handler and remove special on prefix
* fix props implementation of EventHandler
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-03-19 19:48:53 -07:00
1 parent 4bb807a3ce
commit 58f7efafea
19 files changed
+755 -364

No files matched your search

+17 -93
View File
@@ -1,106 +1,18 @@
use generational_box::AnyStorage;
use generational_box::GenerationalBoxId;
use generational_box::SyncStorage;
use generational_box::UnsyncStorage;
use std::any::Any;
use std::any::TypeId;
use std::cell::RefCell;
use std::ops::Deref;
use dioxus_core::prelude::*;
use dioxus_core::ScopeId;
use generational_box::{GenerationalBox, Owner, Storage};
use generational_box::{GenerationalBox, Storage};
use crate::read_impls;
use crate::Readable;
use crate::ReadableRef;
use crate::Writable;
use crate::WritableRef;
use crate::{ReactiveContext, Readable};
/// Run a closure with the given owner.
pub fn with_owner<S: AnyStorage, F: FnOnce() -> R, R>(owner: Owner<S>, f: F) -> R {
let old_owner = set_owner(Some(owner));
let result = f();
set_owner(old_owner);
result
}
/// Set the owner for the current thread.
fn set_owner<S: AnyStorage>(owner: Option<Owner<S>>) -> Option<Owner<S>> {
let id = TypeId::of::<S>();
if id == TypeId::of::<SyncStorage>() {
SYNC_OWNER.with(|cell| {
std::mem::replace(
&mut *cell.borrow_mut(),
owner.map(|owner| {
*(Box::new(owner) as Box<dyn Any>)
.downcast::<Owner<SyncStorage>>()
.unwrap()
}),
)
.map(|owner| *(Box::new(owner) as Box<dyn Any>).downcast().unwrap())
})
} else {
UNSYNC_OWNER.with(|cell| {
std::mem::replace(
&mut *cell.borrow_mut(),
owner.map(|owner| {
*(Box::new(owner) as Box<dyn Any>)
.downcast::<Owner<UnsyncStorage>>()
.unwrap()
}),
)
.map(|owner| *(Box::new(owner) as Box<dyn Any>).downcast().unwrap())
})
}
}
thread_local! {
static SYNC_OWNER: RefCell<Option<Owner<SyncStorage>>> = const { RefCell::new(None) };
static UNSYNC_OWNER: RefCell<Option<Owner<UnsyncStorage>>> = const { RefCell::new(None) };
}
fn current_owner<S: Storage<T>, T>() -> Owner<S> {
let id = TypeId::of::<S>();
let override_owner = if id == TypeId::of::<SyncStorage>() {
SYNC_OWNER.with(|cell| {
let owner = cell.borrow();
owner.clone().map(|owner| {
*(Box::new(owner) as Box<dyn Any>)
.downcast::<Owner<S>>()
.unwrap()
})
})
} else {
UNSYNC_OWNER.with(|cell| {
cell.borrow().clone().map(|owner| {
*(Box::new(owner) as Box<dyn Any>)
.downcast::<Owner<S>>()
.unwrap()
})
})
};
if let Some(owner) = override_owner {
return owner;
}
// Otherwise get the owner from the current reactive context.
match ReactiveContext::current() {
Some(current_reactive_context) => owner_in_scope(current_reactive_context.origin_scope()),
None => owner_in_scope(current_scope_id().expect("in a virtual dom")),
}
}
fn owner_in_scope<S: Storage<T>, T>(scope: ScopeId) -> Owner<S> {
match scope.has_context() {
Some(rt) => rt,
None => {
let owner = S::owner();
scope.provide_context(owner)
}
}
}
use crate::{default_impl, write_impls};
/// CopyValue is a wrapper around a value to make the value mutable and Copy.
///
@@ -181,7 +93,7 @@ impl<T: 'static, S: Storage<T>> CopyValue<T, S> {
/// Create a new CopyValue. The value will be stored in the given scope. When the specified scope is dropped, the value will be dropped.
#[track_caller]
pub fn new_maybe_sync_in_scope(value: T, scope: ScopeId) -> Self {
let owner = owner_in_scope(scope);
let owner = scope.owner();
Self {
value: owner.insert(value),
@@ -270,3 +182,15 @@ impl<T: Copy, S: Storage<T>> Deref for CopyValue<T, S> {
Readable::deref_impl(self)
}
}
impl<T, S: Storage<T>> Clone for CopyValue<T, S> {
fn clone(&self) -> Self {
*self
}
}
impl<T, S: Storage<T>> Copy for CopyValue<T, S> {}
read_impls!(CopyValue<T, S: Storage<T>>);
default_impl!(CopyValue<T, S: Storage<T>>);
write_impls!(CopyValue<T, S: Storage<T>>);
+3 -6
View File
@@ -1,3 +1,4 @@
use crate::read_impls;
use crate::{read::Readable, Memo, ReadableRef};
use dioxus_core::prelude::ScopeId;
use generational_box::UnsyncStorage;
@@ -68,12 +69,6 @@ impl<T: PartialEq + 'static> Readable for GlobalMemo<T> {
}
}
impl<T: PartialEq + 'static> PartialEq for GlobalMemo<T> {
fn eq(&self, other: &Self) -> bool {
std::ptr::eq(self, other)
}
}
/// Allow calling a signal with memo() syntax
///
/// Currently only limited to copy types, though could probably specialize for string/arc/rc
@@ -84,3 +79,5 @@ impl<T: PartialEq + Clone + 'static> Deref for GlobalMemo<T> {
Readable::deref_impl(self)
}
}
read_impls!(GlobalMemo<T> where T: PartialEq);
+3 -6
View File
@@ -6,6 +6,7 @@ use generational_box::UnsyncStorage;
use std::ops::Deref;
use super::get_global_context;
use crate::read_impls;
use crate::Signal;
/// A signal that can be accessed from anywhere in the application and created in a static
@@ -118,12 +119,6 @@ impl<T: 'static> Writable for GlobalSignal<T> {
}
}
impl<T: 'static> PartialEq for GlobalSignal<T> {
fn eq(&self, other: &Self) -> bool {
std::ptr::eq(self, other)
}
}
/// Allow calling a signal with signal() syntax
///
/// Currently only limited to copy types, though could probably specialize for string/arc/rc
@@ -134,3 +129,5 @@ impl<T: Clone + 'static> Deref for GlobalSignal<T> {
Readable::deref_impl(self)
}
}
read_impls!(GlobalSignal<T>);
+343 -102
View File
@@ -1,46 +1,265 @@
use crate::copy_value::CopyValue;
use crate::memo::Memo;
use crate::read::Readable;
use crate::signal::Signal;
use crate::write::Writable;
use crate::{GlobalMemo, GlobalSignal, MappedSignal, ReadOnlySignal, SignalData};
use generational_box::{AnyStorage, Storage};
use std::{
fmt::{Debug, Display},
ops::{Add, Div, Mul, Sub},
};
/// This macro is used to generate a `impl Default` block for any type with the function new_maybe_sync that takes a generic `T`
///
/// # Example
/// ```rust
/// use generational_box::*;
/// use dioxus::prelude::*;
///
/// struct MyCopyValue<T: 'static, S: Storage<T>> {
/// value: CopyValue<T, S>,
/// }
///
/// impl<T: 'static, S: Storage<T>> MyCopyValue<T, S> {
/// fn new_maybe_sync(value: T) -> Self {
/// Self { value: CopyValue::new_maybe_sync(value) }
/// }
/// }
///
/// impl<T: 'static, S: Storage<T>> Readable for MyCopyValue<T, S> {
/// type Target = T;
/// type Storage = S;
///
/// fn try_read_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// }
/// }
///
/// default_impl!(MyCopyValue<T, S: Storage<T>>);
/// ```
#[macro_export]
macro_rules! default_impl {
($ty:ident $(: $extra_bounds:path)? $(, $bound_ty:ident : $bound:path, $vec_bound_ty:ident : $vec_bound:path)?) => {
(
$ty:ident
// Accept generics
< T $(, $gen:ident $(: $gen_bound:path)?)* $(,)?>
// Accept extra bounds
$(
impl<T: Default + 'static, $bound_ty: $bound> Default for $ty<T, $bound_ty> {
#[track_caller]
fn default() -> Self {
Self::new_maybe_sync(Default::default())
}
}
where
$(
$extra_bound_ty:ident: $extra_bound:path
),+
)?
) => {
impl<T: Default + 'static
$(, $gen $(: $gen_bound)?)*
> Default for $ty <T $(, $gen)*>
$(
where
$(
$extra_bound_ty: $extra_bound
),+
)?
{
#[track_caller]
fn default() -> Self {
Self::new_maybe_sync(Default::default())
}
}
}
}
/// This macro is used to generate `impl Display`, `impl Debug`, `impl PartialEq`, and `impl Eq` blocks for any Readable type that takes a generic `T`
///
/// # Example
/// ```rust
/// use generational_box::*;
/// use dioxus::prelude::*;
///
/// struct MyCopyValue<T: 'static, S: Storage<T>> {
/// value: CopyValue<T, S>,
/// }
///
/// impl<T: 'static, S: Storage<T>> Readable for MyCopyValue<T, S> {
/// type Target = T;
/// type Storage = S;
///
/// fn try_read_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// }
/// }
///
/// read_impls!(MyCopyValue<T, S: Storage<T>>);
/// ```
#[macro_export]
macro_rules! read_impls {
($ty:ident $(: $extra_bounds:path)? $(, $bound_ty:ident : $bound:path, $vec_bound_ty:ident : $vec_bound:path)?) => {
impl<T: $($extra_bounds + )? Display + 'static $(,$bound_ty: $bound)?> Display for $ty<T $(, $bound_ty)?> {
#[track_caller]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.with(|v| Display::fmt(v, f))
}
(
$ty:ident
// Accept generics
< T $(, $gen:ident $(: $gen_bound:path)?)* $(,)?>
// Accept extra bounds
$(
where
$(
$extra_bound_ty:ident: $extra_bound:path
),+
)?
) => {
$crate::fmt_impls!{
$ty<
T
$(
, $gen
$(: $gen_bound)?
)*
>
$(
where
$($extra_bound_ty: $extra_bound),*
)?
}
impl<T: $($extra_bounds + )? Debug + 'static $(,$bound_ty: $bound)?> Debug for $ty<T $(, $bound_ty)?> {
#[track_caller]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.with(|v| Debug::fmt(v, f))
}
$crate::eq_impls!{
$ty<
T
$(
, $gen
$(: $gen_bound)?
)*
>
$(
where
$($extra_bound_ty: $extra_bound),*
)?
}
};
}
impl<T: $($extra_bounds + )? PartialEq + 'static $(,$bound_ty: $bound)?> PartialEq<T> for $ty<T $(, $bound_ty)?> {
/// This macro is used to generate `impl Display`, and `impl Debug` blocks for any Readable type that takes a generic `T`
///
/// # Example
/// ```rust
/// use generational_box::*;
/// use dioxus::prelude::*;
///
/// struct MyCopyValue<T: 'static, S: Storage<T>> {
/// value: CopyValue<T, S>,
/// }
///
/// impl<T: 'static, S: Storage<T>> Readable for MyCopyValue<T, S> {
/// type Target = T;
/// type Storage = S;
///
/// fn try_read_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// }
/// }
///
/// fmt_impls!(MyCopyValue<T, S: Storage<T>>);
/// ```
#[macro_export]
macro_rules! fmt_impls {
(
$ty:ident
// Accept generics
< T $(, $gen:ident $(: $gen_bound:path)?)* $(,)?>
// Accept extra bounds
$(
where
$(
$extra_bound_ty:ident: $extra_bound:path
),+
)?
) => {
impl<
T: std::fmt::Display + 'static
$(, $gen $(: $gen_bound)?)*
> std::fmt::Display for $ty<T $(, $gen)*>
$(
where
$($extra_bound_ty: $extra_bound,)*
)?
{
#[track_caller]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.with(|v| std::fmt::Display::fmt(v, f))
}
}
impl<
T: std::fmt::Debug + 'static
$(, $gen $(: $gen_bound)?)*
> std::fmt::Debug for $ty<T $(, $gen)*>
$(
where
$($extra_bound_ty: $extra_bound,)*
)?
{
#[track_caller]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.with(|v| std::fmt::Debug::fmt(v, f))
}
}
};
}
/// This macro is used to generate `impl PartialEq` blocks for any Readable type that takes a generic `T`
///
/// # Example
/// ```rust
/// use generational_box::*;
/// use dioxus::prelude::*;
///
/// struct MyCopyValue<T: 'static, S: Storage<T>> {
/// value: CopyValue<T, S>,
/// }
///
/// impl<T: 'static, S: Storage<T>> Readable for MyCopyValue<T, S> {
/// type Target = T;
/// type Storage = S;
///
/// fn try_read_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// }
/// }
///
/// eq_impls!(MyCopyValue<T, S: Storage<T>>);
/// ```
#[macro_export]
macro_rules! eq_impls {
(
$ty:ident
// Accept generics
< T $(, $gen:ident $(: $gen_bound:path)?)* $(,)?>
// Accept extra bounds
$(
where
$(
$extra_bound_ty:ident: $extra_bound:path
),+
)?
) => {
impl<
T: PartialEq + 'static
$(, $gen $(: $gen_bound)?)*
> PartialEq<T> for $ty<T $(, $gen)*>
$(
where
$($extra_bound_ty: $extra_bound,)*
)?
{
#[track_caller]
fn eq(&self, other: &T) -> bool {
self.with(|v| *v == *other)
@@ -49,9 +268,63 @@ macro_rules! read_impls {
};
}
/// This macro is used to generate `impl Add`, `impl AddAssign`, `impl Sub`, `impl SubAssign`, `impl Mul`, `impl MulAssign`, `impl Div`, and `impl DivAssign` blocks for any Writable type that takes a generic `T`
///
/// # Example
/// ```rust, ignore
/// use generational_box::*;
/// use dioxus::prelude::*;
///
/// struct MyCopyValue<T: 'static, S: Storage<T>> {
/// value: CopyValue<T, S>,
/// }
///
/// impl<T: 'static, S: Storage<T>> Readable for MyCopyValue<T, S> {
/// type Target = T;
/// type Storage = S;
///
/// fn try_read_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// }
/// }
///
/// impl<T: 'static, S: Storage<T>> Writable for MyCopyValue<T, S> {
/// fn try_write_unchecked(
/// &self,
/// ) -> Result<WritableRef<'static, Self>, generational_box::BorrowMutError> {
/// self.value.try_write_unchecked()
///
/// }
///
/// //...
/// }
///
/// write_impls!(MyCopyValue<T, S: Storage<T>>);
/// ```
#[macro_export]
macro_rules! write_impls {
($ty:ident, $bound:path, $vec_bound:path) => {
impl<T: Add<Output = T> + Copy + 'static, S: $bound> std::ops::Add<T> for $ty<T, S> {
(
$ty:ident
// Accept generics
< T $(, $gen:ident $(: $gen_bound:path)?)* $(,)?>
// Accept extra bounds
$(
where
$(
$extra_bound_ty:ident: $extra_bound:path
),+
)?) => {
impl<T: std::ops::Add<Output = T> + Copy + 'static
$(, $gen $(: $gen_bound)?)*
> std::ops::Add<T>
for $ty<T $(, $gen)*>
{
type Output = T;
#[track_caller]
@@ -60,21 +333,33 @@ macro_rules! write_impls {
}
}
impl<T: Add<Output = T> + Copy + 'static, S: $bound> std::ops::AddAssign<T> for $ty<T, S> {
impl<T: std::ops::Add<Output = T> + Copy + 'static
$(, $gen $(: $gen_bound)?)*
> std::ops::AddAssign<T>
for $ty<T $(, $gen)*>
{
#[track_caller]
fn add_assign(&mut self, rhs: T) {
self.with_mut(|v| *v = *v + rhs)
}
}
impl<T: Sub<Output = T> + Copy + 'static, S: $bound> std::ops::SubAssign<T> for $ty<T, S> {
impl<T: std::ops::Sub<Output = T> + Copy + 'static
$(, $gen $(: $gen_bound)?)*
> std::ops::SubAssign<T>
for $ty<T $(, $gen)*>
{
#[track_caller]
fn sub_assign(&mut self, rhs: T) {
self.with_mut(|v| *v = *v - rhs)
}
}
impl<T: Sub<Output = T> + Copy + 'static, S: $bound> std::ops::Sub<T> for $ty<T, S> {
impl<T: std::ops::Sub<Output = T> + Copy + 'static
$(, $gen $(: $gen_bound)?)*
> std::ops::Sub<T>
for $ty<T $(, $gen)*>
{
type Output = T;
#[track_caller]
@@ -83,14 +368,22 @@ macro_rules! write_impls {
}
}
impl<T: Mul<Output = T> + Copy + 'static, S: $bound> std::ops::MulAssign<T> for $ty<T, S> {
impl<T: std::ops::Mul<Output = T> + Copy + 'static
$(, $gen $(: $gen_bound)?)*
> std::ops::MulAssign<T>
for $ty<T $(, $gen)*>
{
#[track_caller]
fn mul_assign(&mut self, rhs: T) {
self.with_mut(|v| *v = *v * rhs)
}
}
impl<T: Mul<Output = T> + Copy + 'static, S: $bound> std::ops::Mul<T> for $ty<T, S> {
impl<T: std::ops::Mul<Output = T> + Copy + 'static
$(, $gen $(: $gen_bound)?)*
> std::ops::Mul<T>
for $ty<T $(, $gen)*>
{
type Output = T;
#[track_caller]
@@ -99,14 +392,22 @@ macro_rules! write_impls {
}
}
impl<T: Div<Output = T> + Copy + 'static, S: $bound> std::ops::DivAssign<T> for $ty<T, S> {
impl<T: std::ops::Div<Output = T> + Copy + 'static
$(, $gen $(: $gen_bound)?)*
> std::ops::DivAssign<T>
for $ty<T $(, $gen)*>
{
#[track_caller]
fn div_assign(&mut self, rhs: T) {
self.with_mut(|v| *v = *v / rhs)
}
}
impl<T: Div<Output = T> + Copy + 'static, S: $bound> std::ops::Div<T> for $ty<T, S> {
impl<T: std::ops::Div<Output = T> + Copy + 'static
$(, $gen $(: $gen_bound)?)*
> std::ops::Div<T>
for $ty<T $(, $gen)*>
{
type Output = T;
#[track_caller]
@@ -116,63 +417,3 @@ macro_rules! write_impls {
}
};
}
read_impls!(CopyValue, S: Storage<T>, S: Storage<Vec<T>>);
default_impl!(CopyValue, S: Storage<T>, S: Storage<Vec<T>>);
write_impls!(CopyValue, Storage<T>, Storage<Vec<T>>);
impl<T: 'static, S: Storage<T>> Clone for CopyValue<T, S> {
fn clone(&self) -> Self {
*self
}
}
impl<T: 'static, S: Storage<T>> Copy for CopyValue<T, S> {}
read_impls!(Signal, S: Storage<SignalData<T>>, S: Storage<SignalData<Vec<T>>>);
default_impl!(Signal, S: Storage<SignalData<T>>, S: Storage<SignalData<Vec<T>>>);
write_impls!(Signal, Storage<SignalData<T>>, Storage<SignalData<Vec<T>>>);
impl<T: 'static, S: Storage<SignalData<T>>> Clone for Signal<T, S> {
fn clone(&self) -> Self {
*self
}
}
impl<T: 'static, S: Storage<SignalData<T>>> Copy for Signal<T, S> {}
read_impls!(
ReadOnlySignal,
S: Storage<SignalData<T>>,
S: Storage<SignalData<Vec<T>>>
);
default_impl!(
ReadOnlySignal,
S: Storage<SignalData<T>>,
S: Storage<SignalData<Vec<T>>>
);
impl<T: 'static, S: Storage<SignalData<T>>> Clone for ReadOnlySignal<T, S> {
fn clone(&self) -> Self {
*self
}
}
impl<T: 'static, S: Storage<SignalData<T>>> Copy for ReadOnlySignal<T, S> {}
read_impls!(Memo: PartialEq);
impl<T: 'static> Clone for Memo<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T: 'static> Copy for Memo<T> {}
read_impls!(GlobalSignal);
default_impl!(GlobalSignal);
read_impls!(GlobalMemo: PartialEq);
read_impls!(MappedSignal, S: AnyStorage, S: AnyStorage);
+3 -1
View File
@@ -1,6 +1,6 @@
use std::{ops::Deref, rc::Rc};
use crate::{read::Readable, ReadableRef};
use crate::{read::Readable, read_impls, ReadableRef};
use dioxus_core::prelude::*;
use generational_box::{AnyStorage, UnsyncStorage};
@@ -88,3 +88,5 @@ where
Readable::deref_impl(self)
}
}
read_impls!(MappedSignal<T, S: AnyStorage>);
+11
View File
@@ -1,3 +1,4 @@
use crate::read_impls;
use crate::write::Writable;
use crate::{read::Readable, ReactiveContext, ReadableRef, Signal};
use crate::{CopyValue, ReadOnlySignal};
@@ -191,3 +192,13 @@ where
Readable::deref_impl(self)
}
}
read_impls!(Memo<T> where T: PartialEq);
impl<T: 'static> Clone for Memo<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T: 'static> Copy for Memo<T> {}
+18
View File
@@ -2,6 +2,7 @@ use crate::{read::Readable, ReadableRef, Signal, SignalData};
use dioxus_core::IntoDynNode;
use std::ops::Deref;
use crate::{default_impl, read_impls};
use dioxus_core::{prelude::IntoAttributeValue, ScopeId};
use generational_box::{Storage, UnsyncStorage};
@@ -128,3 +129,20 @@ impl<T: Clone, S: Storage<SignalData<T>> + 'static> Deref for ReadOnlySignal<T,
Readable::deref_impl(self)
}
}
read_impls!(
ReadOnlySignal<T, S> where
S: Storage<SignalData<T>>
);
default_impl!(
ReadOnlySignal<T, S> where
S: Storage<SignalData<T>>
);
impl<T: 'static, S: Storage<SignalData<T>>> Clone for ReadOnlySignal<T, S> {
fn clone(&self) -> Self {
*self
}
}
impl<T: 'static, S: Storage<SignalData<T>>> Copy for ReadOnlySignal<T, S> {}
+15
View File
@@ -1,3 +1,4 @@
use crate::{default_impl, fmt_impls, write_impls};
use crate::{
read::Readable, write::Writable, CopyValue, GlobalMemo, GlobalSignal, ReactiveContext,
ReadableRef,
@@ -382,6 +383,8 @@ impl<T: 'static, S: Storage<SignalData<T>>> PartialEq for Signal<T, S> {
}
}
impl<T: 'static, S: Storage<SignalData<T>>> Eq for Signal<T, S> {}
/// Allow calling a signal with signal() syntax
///
/// Currently only limited to copy types, though could probably specialize for string/arc/rc
@@ -488,3 +491,15 @@ impl<T: 'static, S: Storage<SignalData<T>>> Drop for SignalSubscriberDrop<T, S>
self.signal.update_subscribers();
}
}
fmt_impls!(Signal<T, S: Storage<SignalData<T>>>);
default_impl!(Signal<T, S: Storage<SignalData<T>>>);
write_impls!(Signal<T, S: Storage<SignalData<T>>>);
impl<T: 'static, S: Storage<SignalData<T>>> Clone for Signal<T, S> {
fn clone(&self) -> Self {
*self
}
}
impl<T: 'static, S: Storage<SignalData<T>>> Copy for Signal<T, S> {}