mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
make GlobalMemo and GlobalSignal not copy or clone
This commit is contained in:
parent
9633cfadde
commit
fc6912d4c0
2 changed files with 26 additions and 32 deletions
|
@ -127,7 +127,7 @@ impl Effect {
|
||||||
///
|
///
|
||||||
/// The signal will be owned by the current component and will be dropped when the component is dropped.
|
/// The signal will be owned by the current component and will be dropped when the component is dropped.
|
||||||
pub fn new(callback: impl FnMut() + 'static) -> Self {
|
pub fn new(callback: impl FnMut() + 'static) -> Self {
|
||||||
let mut myself = Self {
|
let myself = Self {
|
||||||
source: current_scope_id().expect("in a virtual dom"),
|
source: current_scope_id().expect("in a virtual dom"),
|
||||||
inner: EffectInner::new(Box::new(callback)),
|
inner: EffectInner::new(Box::new(callback)),
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,8 +4,7 @@ use crate::rt::CopyValue;
|
||||||
use crate::signal::Signal;
|
use crate::signal::Signal;
|
||||||
use crate::write::Writable;
|
use crate::write::Writable;
|
||||||
use crate::{GlobalMemo, GlobalSignal, ReadOnlySignal, ReadableValueIterator, SignalData};
|
use crate::{GlobalMemo, GlobalSignal, ReadOnlySignal, ReadableValueIterator, SignalData};
|
||||||
use generational_box::UnsyncStorage;
|
use generational_box::Storage;
|
||||||
use generational_box::{AnyStorage, Storage};
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{Debug, Display},
|
fmt::{Debug, Display},
|
||||||
|
@ -23,15 +22,6 @@ macro_rules! read_impls {
|
||||||
}
|
}
|
||||||
)?
|
)?
|
||||||
|
|
||||||
impl<T $(: $extra_bounds)? $(,$bound_ty: $bound)?> std::clone::Clone for $ty<T $(, $bound_ty)?> {
|
|
||||||
#[track_caller]
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
*self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T $(: $extra_bounds)? $(,$bound_ty: $bound)?> Copy for $ty<T $(, $bound_ty)?> {}
|
|
||||||
|
|
||||||
impl<T: $($extra_bounds + )? Display + 'static $(,$bound_ty: $bound)?> Display for $ty<T $(, $bound_ty)?> {
|
impl<T: $($extra_bounds + )? Display + 'static $(,$bound_ty: $bound)?> Display for $ty<T $(, $bound_ty)?> {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
@ -126,6 +116,14 @@ macro_rules! write_impls {
|
||||||
read_impls!(CopyValue, S: Storage<T>, S: Storage<Vec<T>>);
|
read_impls!(CopyValue, S: Storage<T>, S: Storage<Vec<T>>);
|
||||||
write_impls!(CopyValue, Storage<T>, 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> {}
|
||||||
|
|
||||||
impl<T: 'static, S: Storage<Vec<T>>> IntoIterator for CopyValue<Vec<T>, S> {
|
impl<T: 'static, S: Storage<Vec<T>>> IntoIterator for CopyValue<Vec<T>, S> {
|
||||||
type IntoIter = ReadableValueIterator<T, Self>;
|
type IntoIter = ReadableValueIterator<T, Self>;
|
||||||
|
|
||||||
|
@ -139,6 +137,14 @@ impl<T: 'static, S: Storage<Vec<T>>> IntoIterator for CopyValue<Vec<T>, S> {
|
||||||
read_impls!(Signal, S: Storage<SignalData<T>>, S: Storage<SignalData<Vec<T>>>);
|
read_impls!(Signal, S: Storage<SignalData<T>>, S: Storage<SignalData<Vec<T>>>);
|
||||||
write_impls!(Signal, Storage<SignalData<T>>, 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> {}
|
||||||
|
|
||||||
impl<T: 'static, S: Storage<SignalData<Vec<T>>>> IntoIterator for Signal<Vec<T>, S> {
|
impl<T: 'static, S: Storage<SignalData<Vec<T>>>> IntoIterator for Signal<Vec<T>, S> {
|
||||||
type IntoIter = ReadableValueIterator<T, Self>;
|
type IntoIter = ReadableValueIterator<T, Self>;
|
||||||
|
|
||||||
|
@ -155,6 +161,14 @@ read_impls!(
|
||||||
S: Storage<SignalData<Vec<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> {}
|
||||||
|
|
||||||
impl<T: 'static, S: Storage<SignalData<Vec<T>>>> IntoIterator for ReadOnlySignal<Vec<T>, S> {
|
impl<T: 'static, S: Storage<SignalData<Vec<T>>>> IntoIterator for ReadOnlySignal<Vec<T>, S> {
|
||||||
type IntoIter = ReadableValueIterator<T, Self>;
|
type IntoIter = ReadableValueIterator<T, Self>;
|
||||||
|
|
||||||
|
@ -167,24 +181,4 @@ impl<T: 'static, S: Storage<SignalData<Vec<T>>>> IntoIterator for ReadOnlySignal
|
||||||
|
|
||||||
read_impls!(GlobalSignal);
|
read_impls!(GlobalSignal);
|
||||||
|
|
||||||
impl<T: 'static> IntoIterator for GlobalSignal<Vec<T>> {
|
|
||||||
type IntoIter = ReadableValueIterator<T, Self>;
|
|
||||||
|
|
||||||
type Item = <UnsyncStorage as AnyStorage>::Ref<T>;
|
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
|
||||||
self.iter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
read_impls!(GlobalMemo: PartialEq);
|
read_impls!(GlobalMemo: PartialEq);
|
||||||
|
|
||||||
impl<T: PartialEq + 'static> IntoIterator for GlobalMemo<Vec<T>> {
|
|
||||||
type IntoIter = ReadableValueIterator<T, Self>;
|
|
||||||
|
|
||||||
type Item = <UnsyncStorage as AnyStorage>::Ref<T>;
|
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
|
||||||
self.iter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue