Replaced SignalGet and SignalGetCloned with proper traits.

This commit is contained in:
2024-03-04 19:46:22 +00:00
parent 1952dc01d4
commit f9e6a24489

View File

@@ -23,26 +23,32 @@ pub use self::{
use std::marker::Unsize;
/// Signal get
#[extend::ext(name = SignalGet)]
pub impl<S> S
pub trait SignalGet<T> {
/// Gets the signal value, by copying it.
fn get(&self) -> T;
}
impl<S> SignalGet<S::Value> 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> S
pub trait SignalGetCloned<T> {
/// Gets the signal value, by cloning it.
fn get_cloned(&self) -> T;
}
impl<S> SignalGetCloned<S::Value> 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())
}