pub struct AnyVarModify<'a> { /* private fields */ }
Expand description
Mutable reference to a variable value.
The variable will notify an update only on deref_mut
.
Implementations§
Source§impl<'a> AnyVarModify<'a>
impl<'a> AnyVarModify<'a>
Sourcepub fn set(&mut self, new_value: BoxAnyVarValue) -> bool
pub fn set(&mut self, new_value: BoxAnyVarValue) -> bool
Replace the value if not equal.
Note that you can also deref_mut to modify the value.
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.
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).
Sourcepub fn downcast<'s, T: VarValue>(&'s mut self) -> Option<VarModify<'s, 'a, T>>
pub fn downcast<'s, T: VarValue>(&'s mut self) -> Option<VarModify<'s, 'a, T>>
Strongly typed reference, if it is of the same type.
Sourcepub fn value(&self) -> &dyn AnyVarValue
pub fn value(&self) -> &dyn AnyVarValue
Immutable reference to the value.
Note that you can also simply deref to the value.
Sourcepub fn value_mut(&mut self) -> &mut dyn AnyVarValue
pub fn value_mut(&mut self) -> &mut dyn AnyVarValue
Mutable reference to the value.
Getting a mutable reference to the value flags the variable to notify update.
Note that you can also simply deref to the value.
Methods from Deref<Target = dyn AnyVarValue>§
Sourcepub fn downcast_ref<T: VarValue>(&self) -> Option<&T>
pub fn downcast_ref<T: VarValue>(&self) -> Option<&T>
Returns some reference to the inner value if it is of type T
, or
None
if it isn’t.
Sourcepub fn downcast_mut<T: VarValue>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: VarValue>(&mut self) -> Option<&mut T>
Returns some mutable reference to the inner value if it is of type T
, or
None
if it isn’t.
Trait Implementations§
Source§impl<'a> Deref for AnyVarModify<'a>
impl<'a> Deref for AnyVarModify<'a>
Auto Trait Implementations§
impl<'a> Freeze for AnyVarModify<'a>
impl<'a> !RefUnwindSafe for AnyVarModify<'a>
impl<'a> Send for AnyVarModify<'a>
impl<'a> Sync for AnyVarModify<'a>
impl<'a> !Unpin for AnyVarModify<'a>
impl<'a> !UnwindSafe for AnyVarModify<'a>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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