MovingPtr<'_,B: Bundle>
impls Bundle
#20984
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.
relevant issue: #20976
Solution
In order to spawn bundles inside
MovingPtr
s alongside other bundles, we need to be able to nameMovingPtr
as a bundle, which the new associated typeName
onBundle
allows. This type is basically a canonicalized bundle name-type that allows types likeSpawnRelatedBundle
to appear to theBundles
as if they were the bundle they are wrapping:R::RelationshipTarget
. (I need to write tests for this).Other parts of the engine, like observers, rely on
Bundle
being'static
in order to pass around the type without being constrained by lifetimes, which is why I've renamedBundle
toBundleImpl
and madetrait Bundle: BundleImpl + 'static
.Not sure how much I like this personally.
Observers only use the associated trait functions of
Bundle
which shouldn't be affected by the lifetime of the type implementingBundle
(I think).An alternative would be to enforce
Bundle::Name
to impl Bundle itself (which it does, since it's just a tuple of bundles) and have the same components/component order asSelf
so thatBundle
s methods are available'static
(though usingDynamicBundle
this way would certainly be unsafe). That could allow types carryingBundles
in phantom datas to use the associated functions for component order and ids.