File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -32,17 +32,20 @@ fn main() {
3232/// how to handle the field.
3333/// To do this, you can either define a `#[reflect(default = "...")]` attribute on the ignored field, or
3434/// opt-out of `FromReflect`'s auto-derive using the `#[reflect(from_reflect = false)]` attribute.
35+ ///
36+ /// `Box` will forward all reflect methods to its inner value
3537#[ derive( Reflect ) ]
3638#[ reflect( from_reflect = false ) ]
3739pub struct Foo {
3840 a : usize ,
3941 nested : Bar ,
42+ boxed : Box < dyn Reflect > ,
4043 #[ reflect( ignore) ]
4144 _ignored : NonReflectedValue ,
4245}
4346
44- /// This `Bar` type is used in the `nested` field on the `Test` type. We must derive `Reflect` here
45- /// too (or ignore it)
47+ /// This `Bar` type is used in the `nested` and `boxed` fields on the `Test` type.
48+ /// We must derive `Reflect` here too (or ignore it)
4649#[ derive( Reflect ) ]
4750pub struct Bar {
4851 b : usize ,
@@ -58,6 +61,7 @@ fn setup(type_registry: Res<AppTypeRegistry>) {
5861 a : 1 ,
5962 _ignored : NonReflectedValue { _a : 10 } ,
6063 nested : Bar { b : 8 } ,
64+ boxed : Box :: new ( Bar { b : 4 } ) ,
6165 } ;
6266
6367 // 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