@@ -44,7 +44,7 @@ use std::{any::TypeId, collections::HashMap};
44
44
/// [Bundle::component_id]
45
45
pub unsafe trait Bundle : Send + Sync + ' static {
46
46
/// Gets this [Bundle]'s component ids, in the order of this bundle's Components
47
- fn component_id ( components : & mut Components ) -> Vec < ComponentId > ;
47
+ fn component_ids ( components : & mut Components ) -> Vec < ComponentId > ;
48
48
49
49
/// Calls `func`, which should return data for each component in the bundle, in the order of
50
50
/// this bundle's Components
@@ -67,7 +67,7 @@ macro_rules! tuple_impl {
67
67
/// SAFE: TypeInfo is returned in tuple-order. [Bundle::from_components] and [Bundle::get_components] use tuple-order
68
68
unsafe impl <$( $name: Component ) ,* > Bundle for ( $( $name, ) * ) {
69
69
#[ allow( unused_variables) ]
70
- fn component_id ( components: & mut Components ) -> Vec <ComponentId > {
70
+ fn component_ids ( components: & mut Components ) -> Vec <ComponentId > {
71
71
vec![ $( components. get_or_insert_id:: <$name>( ) ) ,* ]
72
72
}
73
73
@@ -206,11 +206,11 @@ impl Bundles {
206
206
) -> & ' a BundleInfo {
207
207
let bundle_infos = & mut self . bundle_infos ;
208
208
let id = self . bundle_ids . entry ( TypeId :: of :: < T > ( ) ) . or_insert_with ( || {
209
- let component_id = T :: component_id ( components) ;
209
+ let component_ids = T :: component_ids ( components) ;
210
210
let id = BundleId ( bundle_infos. len ( ) ) ;
211
211
// SAFE: T::component_id ensures info was created
212
212
let bundle_info = unsafe {
213
- initialize_bundle ( std:: any:: type_name :: < T > ( ) , & component_id , id, components)
213
+ initialize_bundle ( std:: any:: type_name :: < T > ( ) , component_ids , id, components)
214
214
} ;
215
215
bundle_infos. push ( bundle_info) ;
216
216
id
@@ -225,17 +225,15 @@ impl Bundles {
225
225
/// `component_id` must be valid [ComponentId]'s
226
226
unsafe fn initialize_bundle (
227
227
bundle_type_name : & ' static str ,
228
- component_id : & [ ComponentId ] ,
228
+ component_ids : Vec < ComponentId > ,
229
229
id : BundleId ,
230
230
components : & mut Components ,
231
231
) -> BundleInfo {
232
- let mut component_ids = Vec :: new ( ) ;
233
232
let mut storage_types = Vec :: new ( ) ;
234
233
235
- for & component_id in component_id {
234
+ for & component_id in & component_ids {
236
235
// SAFE: component_id exists and is therefore valid
237
236
let component_info = components. get_info_unchecked ( component_id) ;
238
- component_ids. push ( component_id) ;
239
237
storage_types. push ( component_info. storage_type ( ) ) ;
240
238
}
241
239
0 commit comments