"soft" remove EntityRef::get_unchecked_mut
#5610
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
EntityRef::get_unchecked_mut
existing is sort of "in conflict" with the idea that the&World
inEntityRef
is "truly" shared readonly rather than doing interior mutable shenanigans like query (see #5588). So remove it 🤔I am a bit apprehensive about 'just' removing this method since I'm not convinced we have enough interior mutability/world splitting primitives in bevy rn to cover all of the uses that this method might have. Particularly I think you could use this method to accomplish a wildly unsafe unchecked "entity granular borrowck" vs the way
Query
works which is "archetype component id granular" and we don't have an API to do that in bevy atm.Unfortunately (and somewhat ironically)
Query::get_component_unchecked_mut
uses this fn so instead of outright removing, it's just been madepub(crate)
. I am not sure if it is better to instead call the "internal" component getter methods inentity_ref.rs
instead of this.need to think about this all a bit more before this is merged I think
Changelog
EntityRef::get_unchecked_mut
has been removedMigration Guide
Try rearchitecting your code to not require this ( I know not very helpful ), if you have a good use case please share what it is so that it can help inform designing a good API to replace
EntityRef::get_unchecked_mut
:)