pub struct ResMut<'w, T: Resource> { /* private fields */ }Expand description
Mutable reference to a resource in World.
Analogous to Bevy’s ResMut<T>.
Appears in handler function signatures to declare a write dependency. Derefs to the inner value transparently.
§Passing by value
ResMut<T> cannot be Copy (exclusive borrow). To pass the wrapper
to inner functions without moving, call reborrow()
— analogous to the &mut *x pattern for &mut T.
For shared read access, use Res<T>. For optional write access
(no panic if unregistered), use Option<ResMut<T>>.
Construction is pub(crate) — only the dispatch layer creates these.
Implementations§
Source§impl<'w, T: Resource> ResMut<'w, T>
impl<'w, T: Resource> ResMut<'w, T>
Sourcepub fn reborrow(&mut self) -> ResMut<'_, T>
pub fn reborrow(&mut self) -> ResMut<'_, T>
Reborrow as a ResMut<'_, T> with a shorter lifetime.
The original is frozen for the duration of the reborrow, then usable
again. Lets you pass ResMut<T> to inner functions without moving —
analogous to the &mut *x reborrow pattern for &mut T.
ResMut<T> cannot be Copy (exclusive borrow), so this is the
counterpart to Res<T>’s Copy impl when the inner function
signature takes the wrapper itself rather than &mut T.
Trait Implementations§
Source§impl<T: Resource> Param for ResMut<'_, T>
impl<T: Resource> Param for ResMut<'_, T>
Source§type State = ResourceId
type State = ResourceId
ResourceId). Read more