`#[reflect(Trait)]` on a generic struct can't conditionally reflect depending on generic parameters
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Typically a derive macro such as `PartialEq` is clever enough to only work when a struct's generic parameters implement `PartialEq`, by adding trait bounds to the impl. It would be nice to do something similar with `Reflect`:
```rust
#[derive(Reflect, PartialEq)]
#[reflect(PartialEq)] // error
struct Foo {
foo: T,
}
```
Looking at the proc macro it's not immediately obvious to me how do this.
## What solution would you like?
Some way of telling the `Reflect` macro to only reflect traits when the generic type implements them.
## Additional context
This came up in https://github.com/bevyengine/bevy/pull/13348#discussion_r1597879388 When resolved, open a trivial PR to add the `PartialEq` reflection.
Contributor guide
Assessment
This issue has not been assessed yet.