@@ -9,9 +9,9 @@ use bevy::{
9
9
} ,
10
10
platform:: hash:: FixedState ,
11
11
reflect:: {
12
- DynamicEnum , DynamicStruct , DynamicTuple , DynamicTupleStruct , DynamicVariant , FromType ,
13
- NamedField , PartialReflect , Reflect , ReflectKind , StructInfo , StructVariantInfo , TypeInfo ,
14
- TypePath , TypeRegistration , TypeRegistry , TypeRegistryArc ,
12
+ DynamicEnum , DynamicList , DynamicStruct , DynamicTuple , DynamicTupleStruct , DynamicVariant ,
13
+ FromType , NamedField , PartialReflect , Reflect , ReflectKind , StructInfo , StructVariantInfo ,
14
+ TypeInfo , TypePath , TypeRegistration , TypeRegistry , TypeRegistryArc ,
15
15
} ,
16
16
} ;
17
17
use thiserror:: Error ;
@@ -451,6 +451,11 @@ impl<'a, 'b> BsnReflector<'a, 'b> {
451
451
format ! ( "{:?}" , value) ,
452
452
ty. type_path ( ) . into ( ) ,
453
453
) ) ,
454
+ BsnValue :: List ( items) => self . reflect_list ( items, ty) ,
455
+ _ => Err ( ReflectError :: UnexpectedType (
456
+ format ! ( "{:?}" , value) ,
457
+ ty. type_path ( ) . into ( ) ,
458
+ ) ) ,
454
459
}
455
460
}
456
461
@@ -517,6 +522,22 @@ impl<'a, 'b> BsnReflector<'a, 'b> {
517
522
Ok ( ReflectedValue :: new ( ty. type_id ( ) , Box :: new ( dynamic_tuple) ) )
518
523
}
519
524
525
+ fn reflect_list ( & self , items : & [ BsnValue ] , ty : & TypeInfo ) -> ReflectResult < ReflectedValue > {
526
+ if let Ok ( list_info) = ty. as_list ( ) {
527
+ let mut dynamic_list = DynamicList :: default ( ) ;
528
+ let item_type_info = list_info. item_info ( ) . expect ( "Expected typed list" ) ;
529
+ for item in items. iter ( ) {
530
+ dynamic_list. push_box ( self . reflect_value ( item, item_type_info) ?. instance ) ;
531
+ }
532
+ Ok ( ReflectedValue :: new ( ty. type_id ( ) , Box :: new ( dynamic_list) ) )
533
+ } else {
534
+ return Err ( ReflectError :: UnexpectedType (
535
+ format ! ( "{:?}" , items) ,
536
+ format ! ( "{:?}" , ty) ,
537
+ ) ) ;
538
+ }
539
+ }
540
+
520
541
fn reflect_path ( & self , path : & str , ty : Option < & TypeInfo > ) -> ReflectResult < ReflectedValue > {
521
542
let ty = match ty {
522
543
Some ( ty) => ty,
0 commit comments