Skip to content

Make Query<&T> return Ref<T>  #7322

@alice-i-cecile

Description

@alice-i-cecile
          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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useX-ControversialThere is active debate or serious implications around merging this PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions