From 11065974d487ca4b9680ae683a9d356f2f1b6c36 Mon Sep 17 00:00:00 2001 From: Joseph <21144246+JoJoJet@users.noreply.github.com> Date: Thu, 14 Dec 2023 09:26:03 -0800 Subject: [PATCH] Simplify lifetimes in `QueryState` methods (#10937) # Objective The definition of several `QueryState` methods use unnecessary explicit lifetimes, which adds to visual noise. ## Solution Elide the lifetimes. --- crates/bevy_ecs/src/query/state.rs | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index 7ab9bfa95b..8da4e2fcca 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -529,14 +529,11 @@ impl QueryState { /// /// In case of a nonexisting entity or mismatched component, a [`QueryEntityError`] is returned instead. #[inline] - pub(crate) fn get_component<'w, 's, 'r, T: Component>( - &'s self, + pub(crate) fn get_component<'w, T: Component>( + &self, world: UnsafeWorldCell<'w>, entity: Entity, - ) -> Result<&'r T, QueryComponentError> - where - 'w: 'r, - { + ) -> Result<&'w T, QueryComponentError> { let entity_ref = world .get_entity(entity) .ok_or(QueryComponentError::NoSuchEntity)?; @@ -566,14 +563,11 @@ impl QueryState { /// /// If given a nonexisting entity or mismatched component, this will panic. #[inline] - pub(crate) fn component<'w, 's, 'r, T: Component>( - &'s self, + pub(crate) fn component<'w, T: Component>( + &self, world: UnsafeWorldCell<'w>, entity: Entity, - ) -> &'r T - where - 'w: 'r, - { + ) -> &'w T { match self.get_component(world, entity) { Ok(component) => component, Err(error) => { @@ -594,16 +588,13 @@ impl QueryState { /// This function makes it possible to violate Rust's aliasing guarantees. /// You must make sure this call does not result in multiple mutable references to the same component. #[inline] - pub unsafe fn get_component_unchecked_mut<'w, 's, 'r, T: Component>( - &'s self, + pub unsafe fn get_component_unchecked_mut<'w, T: Component>( + &self, world: UnsafeWorldCell<'w>, entity: Entity, last_run: Tick, this_run: Tick, - ) -> Result, QueryComponentError> - where - 'w: 'r, - { + ) -> Result, QueryComponentError> { let entity_ref = world .get_entity(entity) .ok_or(QueryComponentError::NoSuchEntity)?;