[−][src]Struct reax::Var
A mutable variable that is tracked by the reax runtime.
Today this is a wrapper around a RefCell
and a Node
but may be more
generic in the future once GATs are stable.
Implementations
impl<T> Var<T>
[src]
pub fn new(value: T) -> Self
[src]
Creates a new interiorly mutable wrapper around the given value.
pub fn set(&self, value: T)
[src]
Sets the value of the variable, instantly marking all upstream variables
as dirty. This method will panic if any reference given by a call to
mutate
is still alive.
let var = Var::new(1); let double = computed! { var.get_copy() * 2 }; var.set(2); assert!(double.node().is_dirty());
pub fn set_checked(&self, value: T) where
T: PartialEq,
[src]
T: PartialEq,
Sets the value of the variable. Unlike set
, upstream
variables are not marked as dirty if the given value is equal to the
current value.
pub fn mutate(&self) -> RefMut<T>
[src]
Provides a mutable reference to the variable, instantly marking all
upstream variables as dirty. This method will panic if any reference
given by a previous call to mutate
is still alive.
let var = Var::new(1); let double = computed! { var.get_copy() * 2 }; *var.mutate() += 1; assert!(double.node().is_dirty());
Trait Implementations
impl<T: Debug> Debug for Var<T>
[src]
impl<T> Variable for Var<T>
[src]
type Value = T
The type of this variable.
fn node(&self) -> &Node
[src]
fn get(&self) -> Ref<T>
[src]
fn get_non_reactive(&self) -> Ref<T>
[src]
fn get_copy(&self) -> Self::Value where
Self::Value: Copy,
[src]
Self::Value: Copy,
fn map<T, F>(self, func: F) -> ComputedVar<FunctionMapped<Self, T, F>> where
F: FnMut(&Self::Value) -> T,
[src]
F: FnMut(&Self::Value) -> T,
fn map_mutate<T, F>(
self,
initial: T,
func: F
) -> ComputedVar<MutatorMapped<Self, T, F>> where
F: FnMut(&Self::Value, &mut T),
[src]
self,
initial: T,
func: F
) -> ComputedVar<MutatorMapped<Self, T, F>> where
F: FnMut(&Self::Value, &mut T),
fn with_label(self, label: impl Display) -> Self
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for Var<T>
impl<T> !Send for Var<T>
impl<T> !Sync for Var<T>
impl<T> Unpin for Var<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Var<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,