Skip to content

Guarantee uniqueness in RelationshipTarget #25729

Description

@uwuPyxl

What problem does this solve or what need does it fill?

Certain algorithms require a guarantee that the entities in a RelationshipTarget are unique for performant and correct behavior. Specifically this is required for transform propagation, which I am looking to have support user-defined relationships in #25468.

What solution would you like?

RelationshipTarget::Collection::SourceIter should be required to implement EntitySetIterator. With this change Vec<Entity> could not be used as RelationshipTarget::Collection anymore as safe user code edit it to contain duplicates, causing undefined behavior. This is currently the case for Children, and is already causing undefined behavior as seen here #25349. We would need a Vec that prevents duplicates, or use other collections such as EntityIndexSet, see #23296.

What alternative(s) have you considered?

We could add a UniqueRelationshipTarget supertrait that is implemented for every RelationshipTarget which fulfills the requirement above. This way non-unique relationships would still be possible, though I am not aware of a use case for those.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-FeatureA new feature, making something new possibleS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions