File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
crates/bevy_ecs/src/world Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ impl<'w> EntityRef<'w> {
139
139
///
140
140
/// # Safety
141
141
///
142
- /// - The returned reference must never alias a mutable borrow of this component.
142
+ /// - The returned reference must never alias another reference to this component
143
143
/// - The returned reference must not be used after this component is moved which
144
144
/// may happen from **any** `insert_component`, `remove_component` or `despawn`
145
145
/// operation on this world (non-exhaustive list).
@@ -149,7 +149,8 @@ impl<'w> EntityRef<'w> {
149
149
component_id : ComponentId ,
150
150
) -> Option < MutUntyped < ' w > > {
151
151
self . world . components ( ) . get_info ( component_id) ?;
152
- // SAFETY: entity_location is valid, component_id is valid as checked by the line above, world access is promised by the caller
152
+ // SAFETY: entity_location is valid, component_id is valid as checked by the line above,
153
+ // the caller promises that they can uniquely access this component
153
154
get_mut_by_id ( self . world , self . entity , self . location , component_id)
154
155
}
155
156
}
Original file line number Diff line number Diff line change @@ -1480,14 +1480,16 @@ impl World {
1480
1480
let ticks = Ticks {
1481
1481
// SAFETY:
1482
1482
// - index is in-bounds because the column is initialized and non-empty
1483
- // - no other reference to the ticks of the same row can exist at the same time
1483
+ // - the caller of this function has to ensure that they can mutably access this
1484
+ // component for the duration of the `'_` lifetime. This includes access to the `ComponentTicks`
1484
1485
component_ticks : ticks. deref_mut ( ) ,
1485
1486
last_change_tick : self . last_change_tick ( ) ,
1486
1487
change_tick : self . read_change_tick ( ) ,
1487
1488
} ;
1488
1489
1489
1490
Some ( MutUntyped {
1490
- // SAFETY: This function has exclusive access to the world so nothing aliases `ptr`.
1491
+ // SAFETY: the caller of this function has to ensure that they can mutably access this
1492
+ // component for the duration of the `'_` lifetime
1491
1493
value : ptr. assert_unique ( ) ,
1492
1494
ticks,
1493
1495
} )
You can’t perform that action at this time.
0 commit comments