From f9e6a24489499e3ee9ebb58e8bf4c50b451ea9db Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Mon, 4 Mar 2024 19:46:22 +0000 Subject: [PATCH] Replaced `SignalGet` and `SignalGetCloned` with proper traits. --- dynatos-reactive/src/lib.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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()) }