pub struct Computed<T> { /* private fields */ }Expand description
A derived (computed) signal — read-only.
The value is recomputed on each Computed::get from the captured signals,
so it is always up to date:
use dinamika_core::*;
let a = Signal::new(2.0_f32);
let b = Signal::new(3.0_f32);
let sum = {
let (a, b) = (a.clone(), b.clone());
Computed::new(move || a.get() + b.get())
};
assert_eq!(sum.get(), 5.0);
a.set(10.0);
assert_eq!(sum.get(), 13.0);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Computed<T>
impl<T> !Send for Computed<T>
impl<T> !Sync for Computed<T>
impl<T> !UnwindSafe for Computed<T>
impl<T> Freeze for Computed<T>
impl<T> Unpin for Computed<T>
impl<T> UnsafeUnpin for Computed<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more