Allow to mutably query for immutable components #17141
Labels
A-ECS
Entities, components, systems, and events
C-Feature
A new feature, making something new possible
D-Modest
A "normal" level of difficulty; suitable for simple features or challenging fixes
S-Needs-Design
This issue requires design work to think about how it would best be accomplished
What problem does this solve or what need does it fill?
Related #17140
Often you want to lock end users from mutating component, while still having the ability to mutate it in the library internals. For example there is a Child and Parent relationship in the bevy_hierarchy #16662
Currently, this access only limited to the exclusive world access. Querying also can be an option
What solution would you like?
There are two ways of implementing it:
Add new smart pointer analogue to
Mut
that implementsQueryData
and only allows getting mutable access via unsafe methodsOr
Change
Mut
smart pointer in a way to addassume_mut
function if the type it points to is immutable.For that current implementation of immutable components does not work, since
Mut
is generic over any type, butDerefMut
only should be implemented for mutable components. For that we can eitherOr
The text was updated successfully, but these errors were encountered: