@@ -19,7 +19,7 @@ pub enum Anchor {
1919}
2020
2121/// An explicit identifier for an entity in a retained scene.
22- #[ derive( Eq , PartialEq , Hash , Clone ) ]
22+ #[ derive( Debug , Eq , PartialEq , Hash , Clone ) ]
2323pub struct Key ( String ) ;
2424
2525impl < T : Display > From < T > for Key {
@@ -175,9 +175,7 @@ impl RetainScene for DynamicScene {
175175 } ) ;
176176
177177 // Retain the children
178- let anchors = self
179- . children
180- . retain_children :: < T > ( entity, receipt. anchors ) ?;
178+ let anchors = self . children . retain_children ( entity, receipt. anchors ) ?;
181179
182180 // Place the new receipt onto the entity
183181 entity. insert ( Receipt :: < T > {
@@ -192,18 +190,18 @@ impl RetainScene for DynamicScene {
192190
193191/// Trait implemented for collections of scenes that can be retained.
194192pub trait RetainChildren {
195- /// Retains the scenes as children of `entity`, updating the [`Receipt `] in the process .
193+ /// Retains the scenes as children of `entity`, returning the new [`Anchor `] map .
196194 ///
197195 /// See: [`RetainScene::retain`].
198- fn retain_children < T : Send + Sync + ' static > (
196+ fn retain_children (
199197 self ,
200198 entity : & mut EntityWorldMut ,
201199 current_anchors : HashMap < Anchor , Entity > ,
202200 ) -> Result < HashMap < Anchor , Entity > , ConstructError > ;
203201}
204202
205203impl RetainChildren for Vec < DynamicScene > {
206- fn retain_children < T : Send + Sync + ' static > (
204+ fn retain_children (
207205 self ,
208206 entity : & mut EntityWorldMut ,
209207 mut current_anchors : HashMap < Anchor , Entity > ,
@@ -241,7 +239,9 @@ impl RetainChildren for Vec<DynamicScene> {
241239 // first (before deparenting) so that hooks still see the parent when
242240 // they run.
243241 for orphan_id in current_anchors. into_values ( ) {
244- world. entity_mut ( orphan_id) . despawn ( ) ;
242+ if let Ok ( entity) = world. get_entity_mut ( orphan_id) {
243+ entity. despawn ( ) ;
244+ }
245245 }
246246 } ) ;
247247
@@ -323,7 +323,7 @@ impl RetainSceneExt for EntityWorldMut<'_> {
323323 . into_iter ( )
324324 . map ( DynamicPatch :: into_dynamic_scene)
325325 . collect :: < Vec < _ > > ( )
326- . retain_children :: < T > ( self , receipt. anchors ) ?;
326+ . retain_children ( self , receipt. anchors ) ?;
327327
328328 // Place the receipt back onto the entity
329329 self . insert ( Receipt :: < T > {
0 commit comments