Skip to content

Conversation

@Victoronz
Copy link
Contributor

@Victoronz Victoronz commented Feb 11, 2025

Objective

Continuation of #17589 and #16547.

Slices have several methods that return iterators which themselves yield slices, which we have not yet implemented.
An example use is par_iter_many style logic.

Solution

Their implementation is rather straightforward, we simply delegate all impls to [T].
The resulting iterator types need their own wrappers in the form of UniqueEntitySliceIter and UniqueEntitySliceIterMut.

We also add three free functions that cast slices of entity slices to slices of UniqueEntitySlice.
These three should be sufficient, though infinite nesting is achievable with a trait (like TrustedEntityBorrow works over infinite reference nesting), should the need ever arise.

@Victoronz Victoronz added C-Feature A new feature, making something new possible A-ECS Entities, components, systems, and events D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 11, 2025
@alice-i-cecile alice-i-cecile added the X-Uncontroversial This work is generally agreed upon label Feb 11, 2025
@alice-i-cecile
Copy link
Member

As always, clean work. Thanks!

}
}

/// An iterator that yields unique entity/entity borrow slices.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment was a little unclear to me at first. I wasn't sure whether this meant the slices were unique, or the contents of each slice were unique, or the contents of all slices together were unique. Since you have fn windows(), it must be the middle one.

Maybe it would help to use the UniqueEntitySlice type name? That would make the meaning of Unique unambiguous. Maybe something like "An iterator that yields &UniqueEntitySlices. Note that an entity may appear in more than one UniqueEntitySlice, but no more than once within each UniqueEntitySlice."

(And similarly for UniqueEntitySliceIterMut.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've clarified a bit!

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 12, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 12, 2025
Merged via the queue into bevyengine:main with commit 153ce46 Feb 12, 2025
29 checks passed
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-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants