Skip to content

Support multiple unnamed fields in relationship derive #20261

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Azorlogh
Copy link
Contributor

Objective

  • Relationship derives support structs with multiple named fields thanks to the #[relationship] attribute.
  • They don't however support structs with multiple unnamed fields, so this code would fail:
#[derive(Component, Debug)]
#[relationship(relationship_target = TargetedByGeneric<T>)]
struct Targeting<T: Send + Sync + 'static>(#[relationship] Entity, PhantomData<T>);

#[derive(Component, Debug)]
#[relationship_target(relationship = TargetingGeneric<T>)]
struct TargetedBy<T: Send + Sync + 'static>(#[relationship] Vec<Entity>, PhantomData<T>);

Solution

  • Reuse the same logic as for named fields, but for unnamed fields

Testing

  • Trivial

@tim-blackbird tim-blackbird added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 23, 2025
@tim-blackbird tim-blackbird added this to the 0.17 milestone Jul 23, 2025
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a regression test please? This looks fine, but I want to make sure that it works and keeps working.

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 23, 2025
@Azorlogh
Copy link
Contributor Author

Can you add a regression test please? This looks fine, but I want to make sure that it works and keeps working.

Oh right! Added 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants