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 WorldQuery
and QueryData
on Mut
.
#13338
Conversation
8ca8698
to
220b276
Compare
This could reuse |
I was originally thinking of doing that, but was put off of doing so by the fact that the implementation on |
The implementation for |
7068559
to
73d2104
Compare
Don't remember what the Bevy project does to deal with out-of-date PRs, so I used the github UI to rebase on top of main, which is why the three commits were suddenly repeated. |
Yeah, we don't have strong feelings on rebasing vs. merging: do whatever is easiest for you. I agree with @SkiFire13's suggestion above: reducing code duplication is important 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.
Solid stuff. A couple of improvements to the documentation, then this LGTM.
Provides a `WorldQuery` implementation on `Mut<T>` to mirror the implementation on `&mut T`, and give users a way to opt-in to change detection in auto-generated `QueryData::ReadOnly` types.
This replaces the manual copy of `&mut T`'s WorldQuery implementation on `Mut<T>` with a version that simply forwards to `&mut T`. Most trait methods call their respective methods on the forwarding target, though to avoid erroneous references to `&mut T` in the assert message for component access conflicts, `update_component_access` has been left unchanged.
73d2104
to
3e85504
Compare
Oh. #13343 happened. Welp, time to fix my code. |
ff45bc0
to
fed1874
Compare
There we go. |
fed1874
to
c3e17f1
Compare
c3e17f1
to
7dd045b
Compare
Objective
Provides a
WorldQuery
implementation onMut<T>
that forwards to the implementation on&mut T
, and give users a way to opt-in to change detection in auto-generatedQueryData::ReadOnly
types.Fixes #13329.
Solution
I implemented
WorldQuery
onMut<'w, T>
as a forwarding implementation to&mut T
, setting theQueryData::ReadOnly
associated type toRef<'w, T>
. This provides users the ability to explicitly opt-in to change detection in the read-only forms of queries.Testing
A documentation test was added to
Mut
showcasing the new functionality.Changelog
Added
WorldQuery
andQueryData
onbevy_ecs::change_detection::Mut
.