Type Alias bevy::ecs::system::lifetimeless::SResMut

pub type SResMut<T> = ResMut<'static, T>;
Expand description

A ResMut with 'static lifetimes.

Aliased Type§

struct SResMut<T> { /* private fields */ }



impl<'a, T> ResMut<'a, T>where T: Resource + ?Sized,

pub fn into_inner(self) -> &'a mut T

Consume self and return a mutable reference to the contained value while marking self as “changed”.

pub fn reborrow(&mut self) -> Mut<'_, T>

Returns a Mut<> with a smaller lifetime. This is useful if you have &mut ResMut <T>, but you need a Mut<T>.

pub fn map_unchanged<U>(self, f: impl FnOnce(&mut T) -> &mut U) -> Mut<'a, U>where U: ?Sized,

Maps to an inner value by applying a function to the contained reference, without flagging a change.

You should never modify the argument passed to the closure – if you want to modify the data without flagging a change, consider using DetectChangesMut::bypass_change_detection to make your intent explicit.

// When run, zeroes the translation of every entity.
fn reset_positions(mut transforms: Query<&mut Transform>) {
    for transform in &mut transforms {
        // We pinky promise not to modify `t` within the closure.
        // Breaking this promise will result in logic errors, but will never cause undefined behavior.
        let mut translation = transform.map_unchanged(|t| &mut t.translation);
        // Only reset the translation if it isn't already zero;

pub fn as_deref_mut(&mut self) -> Mut<'_, <T as Deref>::Target>where T: DerefMut,

Allows you access to the dereferenced value of this pointer without immediately triggering change detection.

Trait Implementations§


impl<'a, T> AsMut<T> for ResMut<'a, T>where T: Resource,


fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.

impl<'a, T> AsRef<T> for ResMut<'a, T>where T: Resource,


fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.

impl<'a, T> Debug for ResMut<'a, T>where T: Resource + Debug + ?Sized,


fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

impl<'a, T> Deref for ResMut<'a, T>where T: Resource + ?Sized,


type Target = T

The resulting type after dereferencing.

fn deref(&self) -> &<ResMut<'a, T> as Deref>::Target

Dereferences the value.

impl<'a, T> DerefMut for ResMut<'a, T>where T: Resource + ?Sized,


fn deref_mut(&mut self) -> &mut <ResMut<'a, T> as Deref>::Target

Mutably dereferences the value.

impl<'a, T> DetectChanges for ResMut<'a, T>where T: Resource + ?Sized,


fn is_added(&self) -> bool

Returns true if this value was added after the system last ran.

fn is_changed(&self) -> bool

Returns true if this value was added or mutably dereferenced either since the last time the system ran or, if the system never ran, since the beginning of the program. Read more

fn last_changed(&self) -> Tick

Returns the change tick recording the time this data was most recently changed. Read more

impl<'a, T> DetectChangesMut for ResMut<'a, T>where T: Resource + ?Sized,


type Inner = T

The type contained within this smart pointer Read more

fn set_changed(&mut self)

Flags this value as having been changed. Read more

fn set_last_changed(&mut self, last_changed: Tick)

Manually sets the change tick recording the time when this data was last mutated. Read more

fn bypass_change_detection( &mut self ) -> &mut <ResMut<'a, T> as DetectChangesMut>::Inner

Manually bypasses change detection, allowing you to mutate the underlying value without updating the change tick. Read more

impl<'a, T> SystemParam for ResMut<'a, T>where T: Resource,


type State = ComponentId

Used to store data which persists across invocations of a system.

type Item<'w, 's> = ResMut<'w, T>

The item type returned when constructing this system param. The value of this associated type should be Self, instantiated with new lifetimes. Read more

fn init_state( world: &mut World, system_meta: &mut SystemMeta ) -> <ResMut<'a, T> as SystemParam>::State

Registers any World access used by this SystemParam and creates a new instance of this param’s State.

unsafe fn get_param<'w, 's>( _: &'s mut <ResMut<'a, T> as SystemParam>::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick ) -> <ResMut<'a, T> as SystemParam>::Item<'w, 's>

Creates a parameter to be passed into a SystemParamFunction. Read more

fn new_archetype( _state: &mut Self::State, _archetype: &Archetype, _system_meta: &mut SystemMeta )

For the specified Archetype, registers the components accessed by this SystemParam (if applicable).

fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)

Applies any deferred mutations stored in this SystemParam’s state. This is used to apply Commands during apply_deferred.