File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,18 @@ fn main() {
22
22
/// Deriving `Reflect` implements the relevant reflection traits. In this case, it implements the
23
23
/// `Reflect` trait and the `Struct` trait `derive(Reflect)` assumes that all fields also implement
24
24
/// Reflect.
25
+ /// `Box` will forward all reflect methods to its inner value
25
26
#[ derive( Reflect ) ]
26
27
pub struct Foo {
27
28
a : usize ,
28
29
nested : Bar ,
30
+ boxed : Box < dyn Reflect > ,
29
31
#[ reflect( ignore) ]
30
32
_ignored : NonReflectedValue ,
31
33
}
32
34
33
- /// This `Bar` type is used in the `nested` field on the `Test` type. We must derive `Reflect` here
34
- /// too (or ignore it)
35
+ /// This `Bar` type is used in the `nested` and `boxed` fields on the `Test` type.
36
+ /// We must derive `Reflect` here too (or ignore it)
35
37
#[ derive( Reflect ) ]
36
38
pub struct Bar {
37
39
b : usize ,
@@ -46,6 +48,7 @@ fn setup(type_registry: Res<TypeRegistry>) {
46
48
a : 1 ,
47
49
_ignored : NonReflectedValue { _a : 10 } ,
48
50
nested : Bar { b : 8 } ,
51
+ boxed : Box :: new ( Bar { b : 4 } ) ,
49
52
} ;
50
53
51
54
// You can set field values like this. The type must match exactly or this will fail.
You can’t perform that action at this time.
0 commit comments