Skip to content

Commit 52bdff0

Browse files
committed
>:(
1 parent b6a647c commit 52bdff0

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

crates/bevy_ecs/src/entity/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'a> core::iter::ExactSizeIterator for ReserveEntitiesIterator<'a> {}
199199

200200
#[derive(Debug, Default)]
201201
pub struct Entities {
202-
pub meta: Vec<EntityMeta>,
202+
pub(crate) meta: Vec<EntityMeta>,
203203

204204
/// The `pending` and `free_cursor` fields describe three sets of Entity IDs
205205
/// that have been freed or are in the process of being allocated:
@@ -243,6 +243,10 @@ pub struct Entities {
243243
}
244244

245245
impl Entities {
246+
pub fn meta_len(&self) -> usize {
247+
self.meta.len()
248+
}
249+
246250
/// Reserve entity IDs concurrently.
247251
///
248252
/// Storage for entity generation and location is lazily allocated by calling `flush`.

crates/bevy_ecs/src/world/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ impl World {
135135
}
136136

137137
/// Retrieves this world's [Entities] collection mutably
138+
///
139+
/// # Safety
140+
/// Mutable reference must not be used to put the [Entities] data
141+
/// in an invalid state for this [World]
138142
#[inline]
139-
pub fn entities_mut(&mut self) -> &mut Entities {
143+
pub unsafe fn entities_mut(&mut self) -> &mut Entities {
140144
&mut self.entities
141145
}
142146

crates/bevy_render/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl Plugin for RenderPlugin {
189189

190190
// reserve all existing app entities for use in render_app
191191
// they can only be spawned using `get_or_spawn()`
192-
let meta_len = app_world.entities().meta.len();
192+
let meta_len = app_world.entities().meta_len();
193193
render_app
194194
.world
195195
.entities()
@@ -198,7 +198,7 @@ impl Plugin for RenderPlugin {
198198
// flushing as "invalid" ensures that app world entities aren't added as "empty archetype" entities by default
199199
// these entities cannot be accessed without spawning directly onto them
200200
// this _only_ works as expected because clear_entities() is called at the end of every frame.
201-
render_app.world.entities_mut().flush_as_invalid();
201+
unsafe { render_app.world.entities_mut() }.flush_as_invalid();
202202
}
203203

204204
{

0 commit comments

Comments
 (0)