mirror of
https://github.com/Zenithsiz/dynatos.git
synced 2026-02-08 21:09:52 +00:00
Replaced SignalGet and SignalGetCloned with proper traits.
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user