pub struct Var<'c, T>(_);Expand description
Index into the DAG which will give you an Rx variable.
However, to get or set the value you need a shared reference to the DAG.
This value is not computed from other values, instead you set it directly.
Implementations
sourceimpl<'c, T> Var<'c, T>
impl<'c, T> Var<'c, T>
pub fn get<'a>(self, c: impl RxContext<'a, 'c>) -> &'a T where
'c: 'a,
pub fn set<'a>(self, c: impl MutRxContext<'a, 'c>, value: T) where
'c: 'a,
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.
This must be used instead of chaining set and get, since setting a value doesn’t make it
returned by get until the graph is recomputed.
pub 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_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,
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