AnyVarModify

Struct AnyVarModify 

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

Source

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.

Source

pub fn update(&mut self)

Notify an update, even if the value does not actually change.

Source

pub fn tags(&self) -> &[BoxAnyVarValue]

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.

Source

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.

Source

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).

Source

pub fn downcast<'s, T: VarValue>(&'s mut self) -> Option<VarModify<'s, 'a, T>>

Strongly typed reference, if it is of the same type.

Source

pub fn value(&self) -> &dyn AnyVarValue

Immutable reference to the value.

Note that you can also simply deref to the value.

Source

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

Source

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.

Source

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.

Source

pub fn is<T: VarValue>(&self) -> bool

Returns true if the inner type is the same as T.

Trait Implementations§

Source§

impl<'a> Deref for AnyVarModify<'a>

Source§

type Target = dyn AnyVarValue

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> DerefMut for AnyVarModify<'a>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more