pub fn clone_from<
        's,
        CloneImplT: CloneImpl,
        CloneImplResultT: CloneImplResult,
        EntityReplacePolicyT: EntityReplacePolicy<'s>,
    >(
        &mut self,
        src_world: &World,
        clone_impl: &CloneImplT,
        clone_impl_result: &mut CloneImplResultT,
        entity_replace_policy: &'s EntityReplacePolicyT,
    ) {
        let span = span!(Level::INFO, "CloneMerging worlds", source = src_world.id().0, destination = ?self.id());
        let _guard = span.enter();

        let src_storage = unsafe { &(*src_world.storage.get()) };
        let dst_storage = unsafe { &mut (*self.storage.get()) };

        // First check that all the src entities exist in the source world. We're assuming the
        // source data will be available later to replace the data we're about to delete
        for k in entity_replace_policy.src_entities() {
            if !src_world.entity_allocator.is_alive(k) {
                panic!("clone_from assumes all replace_mapping keys exist in the source world");
            }
        }

        // Delete all the data associated with dst_entities. This leaves the
        // associated entities in a dangling state, but we'll fix this later when we copy the
        // data over
        for entity_to_replace in entity_replace_policy.dst_entities() {
            if self.entity_allocator.is_alive(entity_to_replace) {
                let location = self
                    .entity_locations
                    .get(entity_to_replace)
                    .expect("Failed to get location of live entity");
                self.delete_location(location);
            } else {
                panic!(
                    "clone_from assumes all replace_mapping values exist in the destination world"
                );
            }
        }

        // Iterate all archetypes in the src world
        for src_archetype in src_storage.archetypes() {
            let archetype_data = ArchetypeFilterData {
                component_types: self.storage().component_types(),
                tag_types: self.storage().tag_types(),
            };

            let dst_archetype_index = World::find_or_create_archetype_for_clone_move(
                clone_impl,
                src_archetype.description(),
                archetype_data,
                dst_storage,
            );

            // Do the clone_from for this archetype
            dst_storage
                .archetype_mut(dst_archetype_index)
                .unwrap()
                .clone_from(
                    &src_world,
                    src_archetype,
                    dst_archetype_index,
                    &self.entity_allocator,
                    &mut self.entity_locations,
                    clone_impl,
                    clone_impl_result,
                    entity_replace_policy,
                );
        }
    }
/// This will *copy* the data from `src_world` into this world. The logic to do the copy is
/// delegated to the `clone_impl` provided by the user. In addition to simple copying, it's also
/// possible to transform from one type to another. This is useful for cases where you want to
/// read from serializable data (like a physics shape definition) and construct something that
/// isn't serializable (like a handle to a physics body)
///
/// By default, all entities in the new world will be assigned a new Entity. `result_mappings`
/// (if not None) will be populated with the old/new Entities, which allows for mapping data
/// between the old and new world.
///
/// If you want to replace existing entities (for example to hot-reload data from a file,)
/// populate `replace_mappings`. For every entry in this map, the key must exist in the source
/// world and the value must exist in the destination world. All entities in the destination
/// world referenced by this map will be deleted, and the entities copied over will be assigned
/// the same entity. If these constraints are not met, this function will panic.
This will *copy* the data from `src_world` into this world. The logic to do the copy is
delegated to the `clone_impl` provided by the user. In addition to simple copying, it's also
possible to transform from one type to another. This is useful for cases where you want to
read from serializable data (like a physics shape definition) and construct something that
isn't serializable (like a handle to a physics body)

By default, all entities in the new world will be assigned a new Entity. `result_mappings`
(if not None) will be populated with the old/new Entities, which allows for mapping data
between the old and new world.

If you want to replace existing entities (for example to hot-reload data from a file,)
populate `replace_mappings`. For every entry in this map, the key must exist in the source
world and the value must exist in the destination world. All entities in the destination
world referenced by this map will be deleted, and the entities copied over will be assigned
the same entity. If these constraints are not met, this function will panic.
This will * copy * the data from ` src_world ` into this world . The logic to do the copy is delegated to the ` clone_impl ` provided by the user . In addition to simple copying it ' s also possible to transform from one type to another . This is useful for cases where you want to read from serializable data ( like a physics shape definition ) and construct something that isn ' t serializable ( like a handle to a physics body ) By default all entities in the new world will be assigned a new Entity . ` result_mappings ` ( if not None ) will be populated with the old / new Entities which allows for mapping data between the old and new world . If you want to replace existing entities ( for example to hot - reload data from a file ) populate ` replace_mappings ` . For every entry in this map the key must exist in the source world and the value must exist in the destination world . All entities in the destination world referenced by this map will be deleted and the entities copied over will be assigned the same entity . If these constraints are not met this function will panic .
pub fn clone_from<
        's,
        CloneImplT: CloneImpl,
        CloneImplResultT: CloneImplResult,
        EntityReplacePolicyT: EntityReplacePolicy<'s>,
    >(
        &mut self,
        src_world: &World,
        clone_impl: &CloneImplT,
        clone_impl_result: &mut CloneImplResultT,
        entity_replace_policy: &'s EntityReplacePolicyT,
    ) {
        let span = span!(Level::INFO, "CloneMerging worlds", source = src_world.id().0, destination = ?self.id());
        let _guard = span.enter();
        let src_storage = unsafe { &(*src_world.storage.get()) };
        let dst_storage = unsafe { &mut (*self.storage.get()) };
        // First check that all the src entities exist in the source world. We're assuming the
        // source data will be available later to replace the data we're about to delete
        for k in entity_replace_policy.src_entities() {
            if !src_world.entity_allocator.is_alive(k) {
                panic!("clone_from assumes all replace_mapping keys exist in the source world");
            }
        }
        // Delete all the data associated with dst_entities. This leaves the
        // associated entities in a dangling state, but we'll fix this later when we copy the
        // data over
        for entity_to_replace in entity_replace_policy.dst_entities() {
            if self.entity_allocator.is_alive(entity_to_replace) {
                let location = self
                    .entity_locations
                    .get(entity_to_replace)
                    .expect("Failed to get location of live entity");
                self.delete_location(location);
            } else {
                panic!(
                    "clone_from assumes all replace_mapping values exist in the destination world"
                );
            }
        }
        // Iterate all archetypes in the src world
        for src_archetype in src_storage.archetypes() {
            let archetype_data = ArchetypeFilterData {
                component_types: self.storage().component_types(),
                tag_types: self.storage().tag_types(),
            };
            let dst_archetype_index = World::find_or_create_archetype_for_clone_move(
                clone_impl,
                src_archetype.description(),
                archetype_data,
                dst_storage,
            );
            // Do the clone_from for this archetype
            dst_storage
                .archetype_mut(dst_archetype_index)
                .unwrap()
                .clone_from(
                    &src_world,
                    src_archetype,
                    dst_archetype_index,
                    &self.entity_allocator,
                    &mut self.entity_locations,
                    clone_impl,
                    clone_impl_result,
                    entity_replace_policy,
                );
        }
    }
pub fn clone_from < ' s , CloneImplT : CloneImpl , CloneImplResultT : CloneImplResult , EntityReplacePolicyT : EntityReplacePolicy < ' s > , > ( & mut self , src_world : & World , clone_impl : & CloneImplT , clone_impl_result : & mut CloneImplResultT , entity_replace_policy : & ' s EntityReplacePolicyT , ) { let span = span ! ( Level INFO " " source src_world id ( ) 0 destination self id ( ) ) ; let _guard = span . enter ( ) ; let src_storage = unsafe { & ( * src_world . storage . get ( ) ) } ; let dst_storage = unsafe { & mut ( * self . storage . get ( ) ) } ; // First check that all the src entities exist in the source world. We're assuming the // source data will be available later to replace the data we're about to delete for k in entity_replace_policy . src_entities ( ) { if ! src_world . entity_allocator . is_alive ( k ) { panic ! ( " " ) ; } } // Delete all the data associated with dst_entities. This leaves the // associated entities in a dangling state, but we'll fix this later when we copy the // data over for entity_to_replace in entity_replace_policy . dst_entities ( ) { if self . entity_allocator . is_alive ( entity_to_replace ) { let location = self . entity_locations . get ( entity_to_replace ) . expect ( " " ) ; self . delete_location ( location ) ; } else { panic ! ( " " ) ; } } // Iterate all archetypes in the src world for src_archetype in src_storage . archetypes ( ) { let archetype_data = ArchetypeFilterData { component_types : self . storage ( ) . component_types ( ) , tag_types : self . storage ( ) . tag_types ( ) , } ; let dst_archetype_index = World :: find_or_create_archetype_for_clone_move ( clone_impl , src_archetype . description ( ) , archetype_data , dst_storage , ) ; // Do the clone_from for this archetype dst_storage . archetype_mut ( dst_archetype_index ) . unwrap ( ) . clone_from ( & src_world , src_archetype , dst_archetype_index , & self . entity_allocator , & mut self . entity_locations , clone_impl , clone_impl_result , entity_replace_policy , ) ; } }
This will *copy* the data from `src_world` into this world.
This will * copy * the data from ` src_world ` into this world .
&mut self
src_world
&World
clone_impl
&CloneImplT
clone_impl_result
&mut CloneImplResultT
entity_replace_policy
&'s EntityReplacePolicyT
&mut self
src_world
&World
clone_impl
&CloneImplT
clone_impl_result
&mut CloneImplResultT
entity_replace_policy
&'s EntityReplacePolicyT