Skip to content

Commit

Permalink
Docks ⛵
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Mar 17, 2022
1 parent dbc6548 commit 407a2de
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crates/bevy_ecs/src/world/entity_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ impl<'w> EntityRef<'w> {
unsafe { self.get_unchecked::<T>() }
}

/// This allows aliased mutability use after free bugs.
/// Gets an immutable reference to the component of type `T` associated with
/// this entity without ensuring there are no unique borrows active and without
/// ensuring that the returned reference will stay valid.
/// # Safety
/// - Must not be a mutable reference to the component.
/// - Must not use the returned reference after the component is removed
Expand All @@ -78,7 +80,9 @@ impl<'w> EntityRef<'w> {
.map(|value| &*value.cast::<T>())
}

/// This allows aliased mutability and use after free bugs.
/// Gets a mutable reference to the component of type `T` associated with
/// this entity without ensuring there are no other borrows active and without
/// ensuring that the returned reference will stay valid.
/// # Safety
/// - Must not be any other references to the component.
/// - Must not use the returned reference after the component is removed.
Expand Down Expand Up @@ -165,7 +169,9 @@ impl<'w> EntityMut<'w> {
unsafe { self.get_unchecked_mut::<T>() }
}

/// This allows aliased mutability use after free bugs.
/// Gets an immutable reference to the component of type `T` associated with
/// this entity without ensuring there are no unique borrows active and without
/// ensuring that the returned reference will stay valid.
/// # Safety
/// - Must not be a mutable reference to the component.
/// - Must not use the returned reference after the component is removed
Expand All @@ -176,7 +182,9 @@ impl<'w> EntityMut<'w> {
.map(|value| &*value.cast::<T>())
}

/// This allows aliased mutability and use after free bugs.
/// Gets a mutable reference to the component of type `T` associated with
/// this entity without ensuring there are no other borrows active and without
/// ensuring that the returned reference will stay valid.
/// # Safety
/// - Must not be any other references to the component.
/// - Must not use the returned reference after the component is removed.
Expand Down

0 comments on commit 407a2de

Please sign in to comment.