You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: chase_ai_system.rs
    path of file: ./repos/rustrogueliketutorial/chapter-75-darkplaza/src/systems/ai
    
    the code of the file until where you have to start completion: use specs::prelude::*;
use crate::{MyTurn, Chasing, Position, Map, ApplyMove, TileSize};
use std::collecti
    
    fn run(&mut self, data : Self::SystemData) {
        let (mut turns, mut chasing, positions, mut map,
            entities, mut apply_move, sizes) = data;

        let mut targets : HashMap<Entity, (i32, i32)> = HashMap::new();
        let mut end_chase : Vec<Entity> = Vec::new();
        for (entity, _turn, chasing) in (&entities, &turns, &chasing).join() {
            let target_pos = positions.get(chasing.target);
            if let Some(target_pos) = target_pos {
                targets.insert(entity, (target_pos.x, target_pos.y));
            } else {
                end_chase.push(entity);
            }
        }

        for done in end_chase.iter() {
            chasing.remove(*done);
        }
        end_chase.clear();

        let mut turn_done : Vec<Entity> = Vec::new();
        for (entity, pos, _chase, _myturn) in
            (&entities, &positions, &chasing, &turns).join()
        {
            turn_done.push(entity);
            let target_pos = targets[&entity];
            let path;

            if let Some(size) = sizes.get(entity) {
                let mut map_copy = map.clone();
                map_copy.populate_blocked_multi(size.x, size.y);
                path = rltk::a_star_search(
                    map_copy.xy_idx(pos.x, pos.y),
                    map_copy.xy_idx(target_pos.0, target_pos.1),
                    &mut map_copy
                );
            } else {
                path = rltk::a_star_search(
                    map.xy_idx(pos.x, pos.y),
                    map.xy_idx(target_pos.0, target_pos.1),
                    &mut *map
                );
            }
            if path.success && path.steps.len()>1 && path.steps.len()<15 {
                apply_move.insert(entity, ApplyMove{ dest_idx: path.steps[1] }).expect("Unable to insert");
                turn_done.push(entity);
            } else {
                end_chase.push(entity);
            }
        }

        for done in end_chase.iter() {
            chasing.remove(*done);
        }
        for done in turn_done.iter() {
            turns.remove(*done);
        }
    }