Immutable Resources fix#24424
Conversation
…ble-resources-fix
|
I don't know where all the migration guides have gone to, but for future reference: I'd like to add the following to the resources_as_components migration guide: And also the PR number on the top. |
|
The migration guides are in the I would keep this PR separate for logic fixes that should also be in main and then to open a separate one to update the migration guide specifically on the release branch |
chescock
left a comment
There was a problem hiding this comment.
Yeah, having versions of these APIs for resources seems important!
| /// - no other references to the resource exist at the same time | ||
| /// - the resource `R` is mutable | ||
| #[inline] | ||
| pub unsafe fn get_resource_mut_assume_mutable<R: Resource>(self) -> Option<Mut<'w, R>> { |
There was a problem hiding this comment.
Should we change get_resource_mut to delegate to this, like how UnsafeEntityCell::get_mut just calls get_mut_assume_mutable?
kfc35
left a comment
There was a problem hiding this comment.
looks good to me! i agree that get_resource_mut should delegate to the new method
Objective
Fixes #24285.
Solution
Add
UnsafeWorldCell::get_resource_assume_mutable,World::modify_resourceandWorld::modify_resource_by_idand updated the migration guide.Testing
The new methods are essentially identical to their component counterparts.