What problem does this solve or what need does it fill?
For a simple struct with no generic trait bounds, like so, the reflect derive works.
#[derive(Reflect)]
struct MyStruct;
For a struct with one or more generic trait bounds, like so, the reflect derive does not work.
#[derive(Reflect)]
struct MyStruct<T>(PhantomData<T>);
This is because T isn't bound to be Reflect, which makes sense.
Adding a Reflect bound to T would fix this use case.
However, if T may or may not be Reflect, the overall struct cannot derive Reflect.
Normally this could be solved with impl<T: Reflect> Reflect for MyStruct<T>, except that Reflect is a very dangerous and unsafe to implement trait: #[derive(Reflect)] is the "correct" way to implement Reflect.
There should be some way to derive Reflect with additional bounds.
What solution would you like?
Something like an attribute:
#[derive(Reflect)]
#[reflect(where = "T") // Only implements Reflect when `T` is reflect.
struct MyStruct<T>(PhantomData<T>);
This could be used multiple times.
#[derive(Reflect)])
#[reflect(where = "T", where = "Z")]
struct MyStruct<T, Z>(PhantomData<(T, Z)>);
What problem does this solve or what need does it fill?
For a simple struct with no generic trait bounds, like so, the reflect derive works.
For a struct with one or more generic trait bounds, like so, the reflect derive does not work.
This is because
Tisn't bound to beReflect, which makes sense.Adding a
Reflectbound toTwould fix this use case.However, if
Tmay or may not beReflect, the overall struct cannot deriveReflect.Normally this could be solved with
impl<T: Reflect> Reflect for MyStruct<T>, except thatReflectis a very dangerous and unsafe to implement trait:#[derive(Reflect)]is the "correct" way to implementReflect.There should be some way to derive
Reflectwith additional bounds.What solution would you like?
Something like an attribute:
This could be used multiple times.