Skip to content

Commit ce6889b

Browse files
Implement direct mutable dereferencing (#2100)
This PR adds a way to get the underlying mutable reference for it's full lifetime. Context: https://discord.com/channels/691052431525675048/692572690833473578/839255317287796796
1 parent 81279f3 commit ce6889b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

crates/bevy_ecs/src/world/pointer.rs

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ pub struct Mut<'a, T> {
99
pub(crate) change_tick: u32,
1010
}
1111

12+
impl<'a, T> Mut<'a, T> {
13+
pub fn into_inner(self) -> &'a mut T {
14+
self.component_ticks.set_changed(self.change_tick);
15+
self.value
16+
}
17+
}
18+
1219
impl<'a, T> Deref for Mut<'a, T> {
1320
type Target = T;
1421

crates/bevy_ecs/src/world/world_cell.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'w, T> Deref for WorldBorrowMut<'w, T> {
157157

158158
impl<'w, T> DerefMut for WorldBorrowMut<'w, T> {
159159
fn deref_mut(&mut self) -> &mut Self::Target {
160-
self.value.deref_mut()
160+
&mut *self.value
161161
}
162162
}
163163

0 commit comments

Comments
 (0)