Replace some unsafe system executor code with safe code #8274
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
The function
SyncUnsafeCell::from_mut
returns&SyncUnsafeCell<T>
, even though it could return&mut SyncUnsafeCell<T>
. This means it is not possible to callget_mut
on the returned value, so you need to use unsafe code to get exclusive access back.Solution
Return
&mut Self
instead of&Self
inSyncUnsafeCell::from_mut
. This is consistent with my proposal forUnsafeCell::from_mut
: rust-lang/libs-team#198.Replace an unsafe pointer dereference with a safe call to
get_mut
.Changelog
bevy_utils::SyncUnsafeCell::get_mut
now returns a value of type&mut SyncUnsafeCell<T>
. Previously, this returned an immutable reference.Migration Guide
The function
bevy_utils::SyncUnsafeCell::get_mut
now returns a value of type&mut SyncUnsafeCell<T>
. Previously, this returned an immutable reference.