-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Make Query<&T> return Ref<T> #7322
Copy link
Copy link
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useX-Needs-SMEThis type of work requires an SME to approve it.This type of work requires an SME to approve it.
Description
A potentially more controversial option is just to have `&T` return `Ref<T>` instead. Though that might require some benchmarking to ensure there's no perf regression in doing so.
Originally posted by @james7132 in #7306 (comment)
A nice thing about making &T return Ref is that it would make the ReadOnly assoc type on &mut T have an "obvious answer", with this PR it could realistically be &T or Ref. I think the only downside that Mut has that Ref would also have is the fact that you cant pattern match on it, the other issues (shoving mut everywhere and borrowck annoyances from disjoint borrows) dont apply to Ref which is cool.
Boxy's followup.
This would align us further with the behavior of &mut, and ensure that change detection behavior is always available to users.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useX-Needs-SMEThis type of work requires an SME to approve it.This type of work requires an SME to approve it.