@@ -1230,11 +1230,7 @@ impl World {
1230
1230
& mut self ,
1231
1231
entity : Entity ,
1232
1232
) -> Option < Mut < T > > {
1233
- // SAFETY:
1234
- // - `as_unsafe_world_cell` is the only thing that is borrowing world
1235
- // - `as_unsafe_world_cell` provides mutable permission to everything
1236
- // - `&mut self` ensures no other borrows on world data
1237
- unsafe { self . as_unsafe_world_cell ( ) . get_entity ( entity) ?. get_mut ( ) }
1233
+ self . get_entity_mut ( entity) . ok ( ) ?. into_mut ( )
1238
1234
}
1239
1235
1240
1236
/// Temporarily removes a [`Component`] `T` from the provided [`Entity`] and
@@ -3509,14 +3505,7 @@ impl World {
3509
3505
/// This function will panic if it isn't called from the same thread that the resource was inserted from.
3510
3506
#[ inline]
3511
3507
pub fn get_by_id ( & self , entity : Entity , component_id : ComponentId ) -> Option < Ptr < ' _ > > {
3512
- // SAFETY:
3513
- // - `&self` ensures that all accessed data is not mutably aliased
3514
- // - `as_unsafe_world_cell_readonly` provides shared/readonly permission to the whole world
3515
- unsafe {
3516
- self . as_unsafe_world_cell_readonly ( )
3517
- . get_entity ( entity) ?
3518
- . get_by_id ( component_id)
3519
- }
3508
+ self . get_entity ( entity) . ok ( ) ?. get_by_id ( component_id) . ok ( )
3520
3509
}
3521
3510
3522
3511
/// Retrieves a mutable untyped reference to the given `entity`'s [`Component`] of the given [`ComponentId`].
@@ -3530,15 +3519,10 @@ impl World {
3530
3519
entity : Entity ,
3531
3520
component_id : ComponentId ,
3532
3521
) -> Option < MutUntyped < ' _ > > {
3533
- // SAFETY:
3534
- // - `&mut self` ensures that all accessed data is unaliased
3535
- // - `as_unsafe_world_cell` provides mutable permission to the whole world
3536
- unsafe {
3537
- self . as_unsafe_world_cell ( )
3538
- . get_entity ( entity) ?
3539
- . get_mut_by_id ( component_id)
3540
- . ok ( )
3541
- }
3522
+ self . get_entity_mut ( entity)
3523
+ . ok ( ) ?
3524
+ . into_mut_by_id ( component_id)
3525
+ . ok ( )
3542
3526
}
3543
3527
}
3544
3528
0 commit comments