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.
This commit is contained in:
Joseph 2023-12-14 09:26:03 -08:00 committed by GitHub
parent 83fbf48238
commit 11065974d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -529,14 +529,11 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
/// ///
/// In case of a nonexisting entity or mismatched component, a [`QueryEntityError`] is returned instead. /// In case of a nonexisting entity or mismatched component, a [`QueryEntityError`] is returned instead.
#[inline] #[inline]
pub(crate) fn get_component<'w, 's, 'r, T: Component>( pub(crate) fn get_component<'w, T: Component>(
&'s self, &self,
world: UnsafeWorldCell<'w>, world: UnsafeWorldCell<'w>,
entity: Entity, entity: Entity,
) -> Result<&'r T, QueryComponentError> ) -> Result<&'w T, QueryComponentError> {
where
'w: 'r,
{
let entity_ref = world let entity_ref = world
.get_entity(entity) .get_entity(entity)
.ok_or(QueryComponentError::NoSuchEntity)?; .ok_or(QueryComponentError::NoSuchEntity)?;
@ -566,14 +563,11 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
/// ///
/// If given a nonexisting entity or mismatched component, this will panic. /// If given a nonexisting entity or mismatched component, this will panic.
#[inline] #[inline]
pub(crate) fn component<'w, 's, 'r, T: Component>( pub(crate) fn component<'w, T: Component>(
&'s self, &self,
world: UnsafeWorldCell<'w>, world: UnsafeWorldCell<'w>,
entity: Entity, entity: Entity,
) -> &'r T ) -> &'w T {
where
'w: 'r,
{
match self.get_component(world, entity) { match self.get_component(world, entity) {
Ok(component) => component, Ok(component) => component,
Err(error) => { Err(error) => {
@ -594,16 +588,13 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
/// This function makes it possible to violate Rust's aliasing guarantees. /// 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. /// You must make sure this call does not result in multiple mutable references to the same component.
#[inline] #[inline]
pub unsafe fn get_component_unchecked_mut<'w, 's, 'r, T: Component>( pub unsafe fn get_component_unchecked_mut<'w, T: Component>(
&'s self, &self,
world: UnsafeWorldCell<'w>, world: UnsafeWorldCell<'w>,
entity: Entity, entity: Entity,
last_run: Tick, last_run: Tick,
this_run: Tick, this_run: Tick,
) -> Result<Mut<'r, T>, QueryComponentError> ) -> Result<Mut<'w, T>, QueryComponentError> {
where
'w: 'r,
{
let entity_ref = world let entity_ref = world
.get_entity(entity) .get_entity(entity)
.ok_or(QueryComponentError::NoSuchEntity)?; .ok_or(QueryComponentError::NoSuchEntity)?;