mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 14:40:19 +00:00
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:
parent
81279f3090
commit
ce6889b9a8
2 changed files with 8 additions and 1 deletions
|
@ -9,6 +9,13 @@ pub struct Mut<'a, T> {
|
||||||
pub(crate) change_tick: u32,
|
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> {
|
impl<'a, T> Deref for Mut<'a, T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl<'w, T> Deref for WorldBorrowMut<'w, T> {
|
||||||
|
|
||||||
impl<'w, T> DerefMut for WorldBorrowMut<'w, T> {
|
impl<'w, T> DerefMut for WorldBorrowMut<'w, T> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
self.value.deref_mut()
|
&mut *self.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue