@@ -71,7 +71,7 @@ impl Storages {
71
71
let ( components, table_row) =
72
72
fetch_table ( archetypes, self , location, component_id) ?;
73
73
74
- // SAFETY: archetypes only store valid table_rows and the stored component type is T
74
+ // SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
75
75
Some ( (
76
76
components. get_data_unchecked ( table_row) ,
77
77
TickCells {
@@ -130,7 +130,7 @@ impl Storages {
130
130
StorageType :: Table => {
131
131
let ( components, table_row) =
132
132
fetch_table ( archetypes, self , location, component_id) ?;
133
- // SAFETY: archetypes only store valid table_rows and the stored component type is T
133
+ // SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
134
134
Some ( components. get_data_unchecked ( table_row) )
135
135
}
136
136
StorageType :: SparseSet => fetch_sparse_set ( self , component_id) ?. get ( entity) ,
@@ -182,7 +182,7 @@ impl Storages {
182
182
StorageType :: Table => {
183
183
let ( components, table_row) =
184
184
fetch_table ( archetypes, self , location, component_id) ?;
185
- // SAFETY: archetypes only store valid table_rows and the stored component type is T
185
+ // SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
186
186
Some ( components. get_ticks_unchecked ( table_row) )
187
187
}
188
188
StorageType :: SparseSet => fetch_sparse_set ( self , component_id) ?. get_ticks ( entity) ,
@@ -201,7 +201,7 @@ impl Storages {
201
201
/// - `location` must be within bounds of the given archetype and `entity` must exist inside the `archetype`
202
202
/// - `component_id` must be valid
203
203
/// - `components` must come from the same world as `self`
204
- /// - The relevant table row **must be removed** by the caller once all components are taken
204
+ /// - The relevant table row **must be removed** by the caller once all components are taken, without dropping the value
205
205
#[ inline]
206
206
pub ( crate ) unsafe fn take_component < ' a > (
207
207
& ' a mut self ,
@@ -219,7 +219,10 @@ impl Storages {
219
219
let table = & mut self . tables [ location. table_id ] ;
220
220
// SAFETY: archetypes will always point to valid columns
221
221
let components = table. get_column_mut ( component_id) . unwrap ( ) ;
222
- // SAFETY: archetypes only store valid table_rows and the stored component type is T
222
+ // SAFETY:
223
+ // - archetypes only store valid table_rows
224
+ // - index is in bounds as promised by caller
225
+ // - promote is safe because the caller promises to remove the table row without dropping it immediately afterwards
223
226
components
224
227
. get_data_unchecked_mut ( location. table_row )
225
228
. promote ( )
0 commit comments