diff --git a/dynatos-reactive/src/lib.rs b/dynatos-reactive/src/lib.rs index 6526ce5..355b24d 100644 --- a/dynatos-reactive/src/lib.rs +++ b/dynatos-reactive/src/lib.rs @@ -23,26 +23,32 @@ pub use self::{ use std::marker::Unsize; /// Signal get -#[extend::ext(name = SignalGet)] -pub impl S +pub trait SignalGet { + /// Gets the signal value, by copying it. + fn get(&self) -> T; +} + +impl SignalGet for S where S: SignalWith, S::Value: Copy, { - /// Gets the signal value, by copying it fn get(&self) -> S::Value { self.with(|value| *value) } } /// Signal cloned -#[extend::ext(name = SignalGetCloned)] -pub impl S +pub trait SignalGetCloned { + /// Gets the signal value, by cloning it. + fn get_cloned(&self) -> T; +} + +impl SignalGetCloned for S where S: SignalWith, S::Value: Clone, { - /// Gets the signal value, by cloning it fn get_cloned(&self) -> S::Value { self.with(|value| value.clone()) }