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 bundle modification structs store nonnull pointers to different metadata of the world. This is to bypass lifetimes and use (mutable) references to the metadata while spawning, inserting, and removing components.
There are three safety contracts to keep in mind when dereferencing these pointers.
dereferencablehttps://doc.rust-lang.org/std/ptr/index.html#safetyIn all of these cases
Selfstruct, so the only way to violate the lifetime is if any operation on the struct changes or removes metadata. So we assert that no operations can change the metadata. In the case of hooks we enforce this by only allowingDeferredWorldaccess.I made this a seperate pr from the other bundle safety so the safety comments could be discussed separately. They end up being a bit verbose and feel like they clutter the code. So I'd appreciate any suggestions for improving the readability here.