-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
implement iterators that yield UniqueEntitySlice #17796
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
implement iterators that yield UniqueEntitySlice #17796
Conversation
|
As always, clean work. Thanks! |
| } | ||
| } | ||
|
|
||
| /// An iterator that yields unique entity/entity borrow slices. |
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.
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.)
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've clarified a bit!
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_manystyle 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
UniqueEntitySliceIterandUniqueEntitySliceIterMut.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
TrustedEntityBorrowworks over infinite reference nesting), should the need ever arise.