TrackedField

Struct TrackedField 

Source
pub struct TrackedField<'s, T, F> { /* private fields */ }
Expand description

A tracked field in a tracked struct which sets a flag when the value is changed.

Implementations§

Source§

impl<'s, T, F> TrackedField<'s, T, F>
where F: Flags + Clone,

Source

pub fn new(flag: F, track_flags: &'s mut F, value: &'s mut T) -> Self

Create a new tracked field

Source

pub fn force_set(&mut self, value: T)

Forces an update, regardless of whether the value has changed.

Source

pub fn update(&mut self, f: impl FnOnce(&mut T) -> bool) -> bool

Updates the value via a closure It should return true if the value has changed.

Source

pub fn force_update(&mut self, f: impl FnOnce(&mut T))

Forces an update via a closure

Source

pub fn update_opt(&mut self, f: impl FnOnce(&mut T) -> Option<T>) -> bool

Update with an option closure, only sets the flag is Some is returned useful for checked updates Returns true if the value was updated

Source§

impl<T, F> TrackedField<'_, T, F>
where T: PartialEq, F: Flags + Clone,

Source

pub fn set(&mut self, value: T)

Set the value to the new one, but only set the flag whether the value changes

Trait Implementations§

Source§

impl<T, F> AddAssign<T> for TrackedField<'_, T, F>
where T: AddAssign<T>, F: Flags + Clone,

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<'s, T: Debug, F: Debug> Debug for TrackedField<'s, T, F>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T, F> Deref for TrackedField<'_, T, F>

Source§

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

Deref the Field value

Source§

type Target = T

The resulting type after dereferencing.
Source§

impl<T, F> DerefMut for TrackedField<'_, T, F>
where F: Flags + Clone,

Source§

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

Derefs the field value into a mutable reference but also marks the value as changed

Auto Trait Implementations§

§

impl<'s, T, F> Freeze for TrackedField<'s, T, F>
where F: Freeze,

§

impl<'s, T, F> RefUnwindSafe for TrackedField<'s, T, F>

§

impl<'s, T, F> Send for TrackedField<'s, T, F>
where F: Send, T: Send,

§

impl<'s, T, F> Sync for TrackedField<'s, T, F>
where F: Sync, T: Sync,

§

impl<'s, T, F> Unpin for TrackedField<'s, T, F>
where F: Unpin,

§

impl<'s, T, F> !UnwindSafe for TrackedField<'s, T, F>

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