Skip to content

Commit 7eb7896

Browse files
committed
Fix last_changed() and set_last_changed() for MutUntyped (#7619)
# Objective Continuation of #7560. `MutUntyped::last_changed` and `set_last_changed` do not behave as described in their docs. ## Solution Fix them using the same approach that was used for `Mut<>` in #7560.
1 parent 38766fa commit 7eb7896

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

crates/bevy_ecs/src/change_detection.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ macro_rules! change_detection_mut_impl {
185185
}
186186

187187
#[inline]
188-
fn set_last_changed(&mut self, last_change_tick: u32) {
188+
fn set_last_changed(&mut self, last_changed: u32) {
189189
self.ticks
190190
.changed
191-
.set_changed(last_change_tick);
191+
.set_changed(last_changed);
192192
}
193193

194194
#[inline]
@@ -242,9 +242,6 @@ macro_rules! impl_methods {
242242
/// This is useful if you have `&mut
243243
#[doc = stringify!($name)]
244244
/// <T>`, but you need a `Mut<T>`.
245-
///
246-
/// Note that calling [`DetectChangesMut::set_last_changed`] on the returned value
247-
/// will not affect the original.
248245
pub fn reborrow(&mut self) -> Mut<'_, $target> {
249246
Mut {
250247
value: self.value,
@@ -607,9 +604,6 @@ impl<'a> MutUntyped<'a> {
607604

608605
/// Returns a [`MutUntyped`] with a smaller lifetime.
609606
/// This is useful if you have `&mut MutUntyped`, but you need a `MutUntyped`.
610-
///
611-
/// Note that calling [`DetectChangesMut::set_last_changed`] on the returned value
612-
/// will not affect the original.
613607
#[inline]
614608
pub fn reborrow(&mut self) -> MutUntyped {
615609
MutUntyped {
@@ -667,7 +661,7 @@ impl<'a> DetectChanges for MutUntyped<'a> {
667661

668662
#[inline]
669663
fn last_changed(&self) -> u32 {
670-
self.ticks.last_change_tick
664+
self.ticks.changed.tick
671665
}
672666
}
673667

@@ -680,8 +674,8 @@ impl<'a> DetectChangesMut for MutUntyped<'a> {
680674
}
681675

682676
#[inline]
683-
fn set_last_changed(&mut self, last_change_tick: u32) {
684-
self.ticks.last_change_tick = last_change_tick;
677+
fn set_last_changed(&mut self, last_changed: u32) {
678+
self.ticks.changed.set_changed(last_changed);
685679
}
686680

687681
#[inline]

0 commit comments

Comments
 (0)