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

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

A ResMut with 'static lifetimes.

Aliased Type§

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

Implementations

source§

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

source

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

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

source

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>.

source

pub fn map_unchanged<U>(self, f: impl FnOnce(&mut T) -> &mut U) -> Mut<'w, 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;
        translation.set_if_neq(Vec2::ZERO);
    }
}
source

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

source§

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

source§

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

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

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

source§

fn as_ref(&self) -> &T

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

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

source§

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

Formats the value using the given formatter. Read more
source§

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

§

type Target = T

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

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

source§

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

Mutably dereferences the value.
source§

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

source§

fn is_added(&self) -> bool

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

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
source§

fn last_changed(&self) -> Tick

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

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

§

type Inner = T

The type contained within this smart pointer Read more
source§

fn set_changed(&mut self)

Flags this value as having been changed. Read more
source§

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
source§

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

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

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
source§

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.
source§

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
source§

unsafe 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).a Read more
source§

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.
source§

fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_> )

Queues any deferred mutations to be applied at the next apply_deferred.