-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add helper methods to dynamically access relationships #21639
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
base: main
Are you sure you want to change the base?
Add helper methods to dynamically access relationships #21639
Conversation
Change-Id: I0fc5f429189a9a55c233ac353cdb0767ed1502e6
|
Is there a reason why these functions return |
You're right, |
|
I'm not sure how to fix the compile-fail issue. |
| /// ``` | ||
| /// | ||
| /// [`Relationship`]: crate::relationship::Relationship | ||
| pub fn get_relationship_by_id(&self, relationship_id: ComponentId) -> Option<Entity> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this needs a clearer name. You're not getting the relationship itself, you're getting the contained entity.
| /// ``` | ||
| /// | ||
| /// [`RelationshipTarget`]: crate::relationship::RelationshipTarget | ||
| pub fn get_relationship_targets_by_id( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto on naming here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very much think this should exist and the implementation looks good but:
- Naming needs work.
- Needs tests.
- CI needs to pass <3 I've previously just copy-pasted output from CI >.>
|
This seems solid :) |
Objective
#21601 introduced helpers to dynamically access relationship values
The
RelationshipAccessorcan be hard to use manually as it requires manipulating pointers; we can provide helper functions inUnsafeEntityCelland friends to access those.