diff --git a/crates/bevy_ecs/src/change_detection.rs b/crates/bevy_ecs/src/change_detection.rs index 4b81fd455b..3802af55dd 100644 --- a/crates/bevy_ecs/src/change_detection.rs +++ b/crates/bevy_ecs/src/change_detection.rs @@ -635,6 +635,17 @@ impl<'a> MutUntyped<'a> { pub fn as_ref(&self) -> Ptr<'_> { self.value.as_ref() } + + /// Transforms this [`MutUntyped`] into a [`Mut`] with the same lifetime. + /// + /// # Safety + /// - `T` must be the erased pointee type for this [`MutUntyped`]. + pub unsafe fn with_type(self) -> Mut<'a, T> { + Mut { + value: self.value.deref_mut(), + ticks: self.ticks, + } + } } impl<'a> DetectChanges for MutUntyped<'a> {