@@ -800,15 +800,18 @@ fn sorted_remove<T: Eq + Ord + Copy>(source: &mut Vec<T>, remove: &[T]) {
800
800
801
801
// SAFETY: EntityLocation must be valid
802
802
#[ inline]
803
- pub ( crate ) unsafe fn get_mut < T : Component > (
804
- world : & mut World ,
803
+ pub ( crate ) unsafe fn get_mut < ' w , T : Component > (
804
+ world : & ' w mut World ,
805
805
entity : Entity ,
806
806
location : EntityLocation ,
807
- ) -> Option < Mut < ' _ , T > > {
808
- // SAFETY: world access is unique, entity location is valid, and returned component is of type
809
- // T
807
+ ) -> Option < Mut < ' w , T > > {
810
808
let change_tick = world. change_tick ( ) ;
811
809
let last_change_tick = world. last_change_tick ( ) ;
810
+ // SAFETY:
811
+ // - world access is unique
812
+ // - entity location is valid
813
+ // - and returned component is of type T
814
+ // - archetypes and components comes from the same world
812
815
world
813
816
. storages
814
817
. get_component_and_ticks_with_type (
@@ -819,8 +822,12 @@ pub(crate) unsafe fn get_mut<T: Component>(
819
822
location,
820
823
)
821
824
. map ( |( value, ticks) | Mut {
825
+ // SAFETY:
826
+ // - world access is unique and ties world lifetime to `Mut` lifetime
827
+ // - `value` is of type `T`
822
828
value : value. assert_unique ( ) . deref_mut :: < T > ( ) ,
823
829
ticks : Ticks {
830
+ // SAFETY: world access is unique and ties world lifetime to `Mut` lifetime
824
831
component_ticks : ticks. deref_mut ( ) ,
825
832
last_change_tick,
826
833
change_tick,
@@ -836,7 +843,11 @@ pub(crate) unsafe fn get_mut_by_id(
836
843
location : EntityLocation ,
837
844
component_id : ComponentId ,
838
845
) -> Option < MutUntyped > {
839
- // SAFETY: world access is unique, entity location and component_id required to be valid
846
+ // SAFETY:
847
+ // - world access is unique
848
+ // - entity location is valid
849
+ // - and returned component is of type T
850
+ // - archetypes and components comes from the same world
840
851
world
841
852
. storages
842
853
. get_component_and_ticks (
@@ -847,8 +858,10 @@ pub(crate) unsafe fn get_mut_by_id(
847
858
location,
848
859
)
849
860
. map ( |( value, ticks) | MutUntyped {
861
+ // SAFETY: world access is unique and ties world lifetime to `MutUntyped` lifetime
850
862
value : value. assert_unique ( ) ,
851
863
ticks : Ticks {
864
+ // SAFETY: world access is unique and ties world lifetime to `Mut` lifetime
852
865
component_ticks : ticks. deref_mut ( ) ,
853
866
last_change_tick : world. last_change_tick ( ) ,
854
867
change_tick : world. read_change_tick ( ) ,
0 commit comments