-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Make QueryState::transmute
&co validate the world of the &Components
used
#14631
Conversation
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.
Nice clean design, good docs and a regression test! Can't ask for more.
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 this design does work nicely, but I can't help but think that metadata()
is just an arbitrary (and redundant) slice of UnsafeWorldCell
. Rather than introduce a new name / concept, I'm thinking we should just add the missing method to UnsafeWorldCell
and use that instead.
As a proposal, I've pushed that change so we can discuss. Somewhat controversially, it includes From<&World> for UnsafeWorldCell
and changed the parameter in the relevant functions to accept Into<UnsafeWorldCell>
, which allows us to just pass &World
into them. Im pretty sure not including From<&World>
impls for UnsafeWorldCell
was an intentional design decision to make the conversion explicit, but given that it is completely safe to create an UnsafeWorldCell
, and given that it is increasingly used in our APIs, I think adding this impl is both acceptable and desirable.
Agreed here.
I think this is a reasonable proposal: it's nice to keep things simple. |
My initial motivation for making it a separate struct was that I wanted it to be as easy to obtain and use as |
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 like this new diff better :) @SkiFire13 if you're on board with this new plan / diff, let me know and I'll count it as a second approval.
Looks good to me. |
WorldMetadata
and replace QueryState::transmute
's &Components
parameter with itQueryState::transmute
&co validate the world of the &Components
used
Updated the first comment and title to reflect cart's changes |
Objective
Query::transmute
/Query::transmute_filtered
accept any&Components
parameter and this is unsound #14629Solution
QueryState::transmute
,QueryState::transmute_filtered
,QueryState::join
andQueryState::join_filtered
take aimpl Into<UnsafeWorldCell>
instead of a&Components
and validate theirWorldId
Migration Guide
QueryState::transmute
,QueryState::transmute_filtered
,QueryState::join
andQueryState::join_filtered
now take aimpl Into<UnsafeWorldCell>
instead of a&Components