Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[reflect(Trait)] on a generic struct can't conditionally reflect depending on generic parameters #13385

Open
aristaeus opened this issue May 16, 2024 · 0 comments
Labels
A-Reflection Runtime information about types C-Usability A simple quality-of-life change that makes Bevy easier to use

Comments

@aristaeus
Copy link
Contributor

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:

#[derive(Reflect, PartialEq)]
#[reflect(PartialEq)] // error
struct Foo<T> {
    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 #13348 (comment) When resolved, open a trivial PR to add the PartialEq reflection.

@aristaeus aristaeus added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels May 16, 2024
@ItsDoot ItsDoot added C-Usability A simple quality-of-life change that makes Bevy easier to use A-Reflection Runtime information about types and removed C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Usability A simple quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

2 participants