lifetime related cleanup in entity_ref.rs
(#5611)
# Objective EntityMut::world takes &mut self instead of &self I don't see any reason for this. EntityRef is overly restrictive with fn world and could return &'w World --- ## Changelog - EntityRef now implements Copy and Clone - EntityRef::world is now fn(&self) -> &'w World instead of fn(&mut self) -> &World - EntityMut::world is now fn(&self) -> &World instead of fn(&mut self) -> &World
This commit is contained in:
parent
05afbc6815
commit
404b4fc0eb
@ -11,6 +11,7 @@ use bevy_ptr::{OwningPtr, Ptr, UnsafeCellDeref};
|
||||
use std::{any::TypeId, cell::UnsafeCell};
|
||||
|
||||
/// A read-only reference to a particular [`Entity`] and all of its components
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct EntityRef<'w> {
|
||||
world: &'w World,
|
||||
entity: Entity,
|
||||
@ -44,7 +45,7 @@ impl<'w> EntityRef<'w> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn world(&mut self) -> &World {
|
||||
pub fn world(&self) -> &'w World {
|
||||
self.world
|
||||
}
|
||||
|
||||
@ -497,7 +498,7 @@ impl<'w> EntityMut<'w> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn world(&mut self) -> &World {
|
||||
pub fn world(&self) -> &World {
|
||||
self.world
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user