pub struct Var<'c, T>(_);
Expand description
Implementations
sourceimpl<'c, T> Var<'c, T>
impl<'c, T> Var<'c, T>
sourcepub fn set<'a>(self, c: impl MutRxContext<'a, 'c>, value: T) where
'c: 'a,
pub fn set<'a>(self, c: impl MutRxContext<'a, 'c>, value: T) where
'c: 'a,
Write a new value to the variable. The changes will be applied on recompute.
sourcepub fn modify<'a, F: FnOnce(&T) -> T>(
self,
c: impl MutRxContext<'a, 'c>,
modify: F
) where
'c: 'a,
pub fn modify<'a, F: FnOnce(&T) -> T>(
self,
c: impl MutRxContext<'a, 'c>,
modify: F
) where
'c: 'a,
Apply a transformation to the latest value. If Var::set this will apply to the recently-set value. This must be used instead of chaining Var::set and Var::get, since setting a value doesn’t make it returned by Var::get until the graph is recomputed.
Like set
the changes only actually reflect in Var::get on recompute.
sourcepub fn derive<U, GetFn: Fn(&T) -> &U, SetFn: Fn(&T, U) -> T>(
self,
get: GetFn,
set: SetFn
) -> DVar<'c, T, U, GetFn, SetFn>
pub fn derive<U, GetFn: Fn(&T) -> &U, SetFn: Fn(&T, U) -> T>(
self,
get: GetFn,
set: SetFn
) -> DVar<'c, T, U, GetFn, SetFn>
Create a view of part of the variable.
Do know that SetFn
will take the most recently-set value even if the graph hasn’t been recomputed.
This means you can create multiple derive
s 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.
sourcepub fn derive_using_clone<U, GetFn: Fn(&T) -> &U, SetFn: Fn(&mut T, U)>(
self,
get: GetFn,
set: SetFn
) -> DVar<'c, T, U, GetFn, CloneSetFn<T, U, SetFn>> where
T: Clone,
pub fn derive_using_clone<U, GetFn: Fn(&T) -> &U, SetFn: Fn(&mut T, U)>(
self,
get: GetFn,
set: SetFn
) -> DVar<'c, T, U, GetFn, CloneSetFn<T, U, SetFn>> where
T: Clone,
Create a view of part of the variable, which clones the value on set.
Do know that SetFn
will take the most recently-set value even if the graph hasn’t been recomputed.
This means you can create multiple derive
s 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
impl<'c, T> Copy for Var<'c, T>
Auto Trait Implementations
impl<'c, T> RefUnwindSafe for Var<'c, T> where
T: RefUnwindSafe,
impl<'c, T> Send for Var<'c, T> where
T: Send,
impl<'c, T> Sync for Var<'c, T> where
T: Sync,
impl<'c, T> Unpin for Var<'c, T> where
T: Unpin,
impl<'c, T> UnwindSafe for Var<'c, T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more