[][src]Struct reax::Var

pub struct Var<T> { /* fields omitted */ }

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]

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.

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

impl<T> UnwindSafe for Var<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.