Skip to content

Commit 12f1a24

Browse files
committed
move invariants to world_mut
1 parent 1d5fa18 commit 12f1a24

File tree

3 files changed

+60
-165
lines changed

3 files changed

+60
-165
lines changed

crates/bevy_ecs/src/world/entity_ref.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,14 @@ impl<'w> EntityRef<'w> {
7676

7777
#[inline]
7878
pub fn contains_id(&self, component_id: ComponentId) -> bool {
79-
// SAFETY:
80-
// - `EntityRef` existing requires there not to be a `&mut World`
81-
unsafe {
82-
self.as_unsafe_world_cell_readonly()
83-
.contains_id(component_id)
84-
}
79+
self.as_unsafe_world_cell_readonly()
80+
.contains_id(component_id)
8581
}
8682

8783
#[inline]
8884
pub fn contains_type_id(&self, type_id: TypeId) -> bool {
89-
// SAFETY:
90-
// - `EntityRef` existing requires there not to be a `&mut World`
91-
unsafe {
92-
self.as_unsafe_world_cell_readonly()
93-
.contains_type_id(type_id)
94-
}
85+
self.as_unsafe_world_cell_readonly()
86+
.contains_type_id(type_id)
9587
}
9688

9789
#[inline]
@@ -216,22 +208,14 @@ impl<'w> EntityMut<'w> {
216208

217209
#[inline]
218210
pub fn contains_id(&self, component_id: ComponentId) -> bool {
219-
// SAFETY:
220-
// - `EntityMut` has exclusive access on world so noone else can have a `&mut World`
221-
unsafe {
222-
self.as_unsafe_world_cell_readonly()
223-
.contains_id(component_id)
224-
}
211+
self.as_unsafe_world_cell_readonly()
212+
.contains_id(component_id)
225213
}
226214

227215
#[inline]
228216
pub fn contains_type_id(&self, type_id: TypeId) -> bool {
229-
// SAFETY:
230-
// - `EntityMut` has exclusive access on world so noone else can have a `&mut World`
231-
unsafe {
232-
self.as_unsafe_world_cell_readonly()
233-
.contains_type_id(type_id)
234-
}
217+
self.as_unsafe_world_cell_readonly()
218+
.contains_type_id(type_id)
235219
}
236220

237221
#[inline]

0 commit comments

Comments
 (0)