pub struct DVar<'c, S, T, GetFn: Fn(&S) -> &T, SetFn: Fn(&S, T) -> S> { /* private fields */ }Expand description
View and mutate a part of a Var.
Implementations§
Source§impl<'c, S, T, GetFn: Fn(&S) -> &T, SetFn: Fn(&S, T) -> S> DVar<'c, S, T, GetFn, SetFn>
impl<'c, S, T, GetFn: Fn(&S) -> &T, SetFn: Fn(&S, T) -> S> DVar<'c, S, T, GetFn, SetFn>
Sourcepub fn get<'a>(&self, c: impl RxContext<'a, 'c>) -> &'a Twhere
S: 'a,
'c: 'a,
pub fn get<'a>(&self, c: impl RxContext<'a, 'c>) -> &'a Twhere
S: 'a,
'c: 'a,
Read the part of the variable this view gets.
Sourcepub fn set<'a>(&self, c: impl MutRxContext<'a, 'c>, value: T)where
S: 'a,
'c: 'a,
pub fn set<'a>(&self, c: impl MutRxContext<'a, 'c>, value: T)where
S: 'a,
'c: 'a,
Write a new value to the part of the variable this view gets.
Do know that this uses the most recently-set value even if the graph hasn’t been recomputed.
This means you can create multiple derives and set them all before recompute, and you don’t have to worry
about the later derived values setting their part on the stale whole.
Trait Implementations§
Auto Trait Implementations§
impl<'c, S, T, GetFn, SetFn> Freeze for DVar<'c, S, T, GetFn, SetFn>
impl<'c, S, T, GetFn, SetFn> RefUnwindSafe for DVar<'c, S, T, GetFn, SetFn>
impl<'c, S, T, GetFn, SetFn> Send for DVar<'c, S, T, GetFn, SetFn>
impl<'c, S, T, GetFn, SetFn> Sync for DVar<'c, S, T, GetFn, SetFn>
impl<'c, S, T, GetFn, SetFn> Unpin for DVar<'c, S, T, GetFn, SetFn>
impl<'c, S, T, GetFn, SetFn> UnwindSafe for DVar<'c, S, T, GetFn, SetFn>
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