Skip to content

Commit

Permalink
Implement direct mutable dereferencing (bevyengine#2100)
Browse files Browse the repository at this point in the history
This PR adds a way to get the underlying mutable reference for it's full lifetime.

Context:
https://discord.com/channels/691052431525675048/692572690833473578/839255317287796796
  • Loading branch information
TheRawMeatball authored and ostwilkens committed Jul 27, 2021
1 parent 8116644 commit 01db02d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crates/bevy_ecs/src/world/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ pub struct Mut<'a, T> {
pub(crate) change_tick: u32,
}

impl<'a, T> Mut<'a, T> {
pub fn into_inner(self) -> &'a mut T {
self.component_ticks.set_changed(self.change_tick);
self.value
}
}

impl<'a, T> Deref for Mut<'a, T> {
type Target = T;

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/world/world_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<'w, T> Deref for WorldBorrowMut<'w, T> {

impl<'w, T> DerefMut for WorldBorrowMut<'w, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.value.deref_mut()
&mut *self.value
}
}

Expand Down

0 comments on commit 01db02d

Please sign in to comment.