DVar

Struct DVar 

Source
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>

Source

pub fn get<'a>(&self, c: impl RxContext<'a, 'c>) -> &'a T
where S: 'a, 'c: 'a,

Read the part of the variable this view gets.

Source

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§

Source§

impl<'c, S: Debug, T: Debug, GetFn: Debug + Fn(&S) -> &T, SetFn: Debug + Fn(&S, T) -> S> Debug for DVar<'c, S, T, GetFn, SetFn>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'c, S, T, GetFn, SetFn> Freeze for DVar<'c, S, T, GetFn, SetFn>
where GetFn: Freeze, SetFn: Freeze,

§

impl<'c, S, T, GetFn, SetFn> RefUnwindSafe for DVar<'c, S, T, GetFn, SetFn>
where GetFn: RefUnwindSafe, SetFn: RefUnwindSafe, S: RefUnwindSafe,

§

impl<'c, S, T, GetFn, SetFn> Send for DVar<'c, S, T, GetFn, SetFn>
where GetFn: Send, SetFn: Send, S: Send,

§

impl<'c, S, T, GetFn, SetFn> Sync for DVar<'c, S, T, GetFn, SetFn>
where GetFn: Sync, SetFn: Sync, S: Sync,

§

impl<'c, S, T, GetFn, SetFn> Unpin for DVar<'c, S, T, GetFn, SetFn>
where GetFn: Unpin, SetFn: Unpin, S: Unpin,

§

impl<'c, S, T, GetFn, SetFn> UnwindSafe for DVar<'c, S, T, GetFn, SetFn>
where GetFn: UnwindSafe, SetFn: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.