File tree 3 files changed +12
-4
lines changed 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ impl<'a> core::iter::ExactSizeIterator for ReserveEntitiesIterator<'a> {}
199
199
200
200
#[ derive( Debug , Default ) ]
201
201
pub struct Entities {
202
- pub meta : Vec < EntityMeta > ,
202
+ pub ( crate ) meta : Vec < EntityMeta > ,
203
203
204
204
/// The `pending` and `free_cursor` fields describe three sets of Entity IDs
205
205
/// that have been freed or are in the process of being allocated:
@@ -243,6 +243,10 @@ pub struct Entities {
243
243
}
244
244
245
245
impl Entities {
246
+ pub fn meta_len ( & self ) -> usize {
247
+ self . meta . len ( )
248
+ }
249
+
246
250
/// Reserve entity IDs concurrently.
247
251
///
248
252
/// Storage for entity generation and location is lazily allocated by calling `flush`.
Original file line number Diff line number Diff line change @@ -135,8 +135,12 @@ impl World {
135
135
}
136
136
137
137
/// 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]
138
142
#[ inline]
139
- pub fn entities_mut ( & mut self ) -> & mut Entities {
143
+ pub unsafe fn entities_mut ( & mut self ) -> & mut Entities {
140
144
& mut self . entities
141
145
}
142
146
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ impl Plugin for RenderPlugin {
189
189
190
190
// reserve all existing app entities for use in render_app
191
191
// 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 ( ) ;
193
193
render_app
194
194
. world
195
195
. entities ( )
@@ -198,7 +198,7 @@ impl Plugin for RenderPlugin {
198
198
// flushing as "invalid" ensures that app world entities aren't added as "empty archetype" entities by default
199
199
// these entities cannot be accessed without spawning directly onto them
200
200
// 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 ( ) ;
202
202
}
203
203
204
204
{
You can’t perform that action at this time.
0 commit comments