pub struct Mut<'w, T> { /* private fields */ }Expand description
A smart pointer providing mutable access to a component that defers
change-tick stamping to DerefMut. Holding a Mut<T> without writing
through it leaves the component’s changed_tick untouched, so
query_changed and incremental extraction see only entities that were
actually mutated.
§Interior mutability
Components that use interior mutability (AtomicUsize, Mutex<T>, etc.)
can be mutated through Deref without triggering DerefMut. In that
case, call set_changed() explicitly to stamp the
change tick and ensure query_changed reports the modification.
Implementations§
Source§impl<T> Mut<'_, T>
impl<T> Mut<'_, T>
Sourcepub fn set_changed(&mut self)
pub fn set_changed(&mut self)
Manually stamp this component’s changed_tick at the current tick.
Use this when mutating through interior mutability (e.g., atomics)
where DerefMut is not triggered. Has no effect if the component
was already stamped by DerefMut in the same tick.