pub struct VarModify<'a, T: VarValue> { /* private fields */ }
Expand description
Represents the current value in a Var::modify
handler.
Implementations§
source§impl<'a, T: VarValue> VarModify<'a, T>
impl<'a, T: VarValue> VarModify<'a, T>
sourcepub fn set(&mut self, new_value: T)
pub fn set(&mut self, new_value: T)
Replace the value.
The variable will update if the new value is not equal to the previous after all modify closures apply.
sourcepub fn to_mut(&mut self) -> &mut T
pub fn to_mut(&mut self) -> &mut T
Returns a mutable reference for modification.
Note that this clones the current value if this is the first modify closure requesting it.
The variable will update if the new value is not equal to the previous after all modify closures apply.
Custom tags that will be shared with the var hooks if the value updates.
The tags where set by previous modify closures or this one during this update cycle, so tags can also be used to communicate between modify closures.
sourcepub fn push_tag(&mut self, tag: impl AnyVarValue)
pub fn push_tag(&mut self, tag: impl AnyVarValue)
Add a custom tag object that will be shared with the var hooks if the value updates.
Add all custom tags.
sourcepub fn set_modify_importance(&mut self, importance: usize)
pub fn set_modify_importance(&mut self, importance: usize)
Sets a custom AnyVar::modify_importance
value.
Note that the modify info is already automatically set, using a custom value here can easily break all future modify requests for this variable. The importance is set even if the variable does not update (no actual value change or update request).
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for VarModify<'a, T>where
T: Freeze,
impl<'a, T> !RefUnwindSafe for VarModify<'a, T>
impl<'a, T> Send for VarModify<'a, T>
impl<'a, T> Sync for VarModify<'a, T>
impl<'a, T> Unpin for VarModify<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for VarModify<'a, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more