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
This commit is contained in:
TheRawMeatball 2021-05-05 19:35:07 +00:00
parent 81279f3090
commit ce6889b9a8
2 changed files with 8 additions and 1 deletions

View file

@ -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;

View file

@ -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
}
}