Skip to content

Commit 091856b

Browse files
tweak safety comments
1 parent 7a18fb1 commit 091856b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

crates/bevy_ecs/src/reflect.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub struct ReflectComponentFns {
5252
/// Function pointer implementing [`ReflectComponent::reflect()`].
5353
pub reflect: fn(&World, Entity) -> Option<&dyn Reflect>,
5454
/// Function pointer implementing [`ReflectComponent::reflect_mut()`].
55-
/// The function may only be called with a InteriorMutableWorld that can be used to access the relevant component on the given entity
55+
/// SAFETY: The function may only be called with an InteriorMutableWorld that can be used to mutably access the relevant component on the given entity
5656
pub reflect_mut: unsafe fn(InteriorMutableWorld<'_>, Entity) -> Option<Mut<'_, dyn Reflect>>,
5757
/// Function pointer implementing [`ReflectComponent::copy()`].
5858
pub copy: fn(&World, &mut World, Entity, Entity),
@@ -124,7 +124,7 @@ impl ReflectComponent {
124124
/// # Safety
125125
/// This method does not prevent you from having two mutable pointers to the same data,
126126
/// violating Rust's aliasing rules. To avoid this:
127-
/// * Only call this method with a [`InteriorMutableWorld`] that may be used to access the component on the entity `entity`
127+
/// * Only call this method with a [`InteriorMutableWorld`] that may be used to mutably access the component on the entity `entity`
128128
/// * Don't call this method more than once in the same scope for a given [`Component`].
129129
pub unsafe fn reflect_unchecked_mut<'a>(
130130
&self,
@@ -264,6 +264,7 @@ pub struct ReflectResourceFns {
264264
/// Function pointer implementing [`ReflectResource::reflect()`].
265265
pub reflect: fn(&World) -> Option<&dyn Reflect>,
266266
/// Function pointer implementing [`ReflectResource::reflect_unchecked_mut()`].
267+
/// SAFETY: The function may only be called with an InteriorMutableWorld that can be used to mutably access the relevant resource
267268
pub reflect_unchecked_mut: unsafe fn(InteriorMutableWorld<'_>) -> Option<Mut<'_, dyn Reflect>>,
268269
/// Function pointer implementing [`ReflectResource::copy()`].
269270
pub copy: fn(&World, &mut World),
@@ -319,7 +320,7 @@ impl ReflectResource {
319320
/// # Safety
320321
/// This method does not prevent you from having two mutable pointers to the same data,
321322
/// violating Rust's aliasing rules. To avoid this:
322-
/// * Only call this method with a [`InteriorMutableWorld`] which can be used to access the resource.
323+
/// * Only call this method with a [`InteriorMutableWorld`] which can be used to mutably access the resource.
323324
/// * Don't call this method more than once in the same scope for a given [`Resource`].
324325
pub unsafe fn reflect_unchecked_mut<'w>(
325326
&self,

crates/bevy_ecs/src/world/entity_ref.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<'w> EntityRef<'w> {
142142
let info = self.world.components().get_info(component_id)?;
143143
// SAFETY:
144144
// - entity_location and entity are valid
145-
// . component_id is valid as checked by the line above
145+
// - component_id is valid as checked by the line above
146146
// - the storage type is accurate as checked by the fetched ComponentInfo
147147
unsafe {
148148
self.world.get_component(
@@ -790,7 +790,7 @@ pub(crate) unsafe fn get_mut<T: Component>(
790790
// SAFETY:
791791
// - world access is unique
792792
// - entity location is valid
793-
// - and returned component is of type T
793+
// - returned component is of type T
794794
world
795795
.get_component_and_ticks_with_type(
796796
TypeId::of::<T>(),
@@ -821,7 +821,7 @@ pub(crate) unsafe fn get_mut_by_id(
821821
// SAFETY:
822822
// - world access is unique
823823
// - entity location is valid
824-
// - and returned component is of type T
824+
// - returned component is of type T
825825
world
826826
.get_component_and_ticks(component_id, info.storage_type(), entity, location)
827827
.map(|(value, ticks)| MutUntyped {

0 commit comments

Comments
 (0)