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: _type.rs
    path of file: ./repos/mk48/common/src/entity
    
    the code of the file until where you have to start completion: use crate::altitude::Altitude;
use crate::entity::{
    Armament, EntityData, EntityKind, EntitySubKind, Exhaust, Sensor, Sensors, Turret,
};
use crate::ticks::Ticks;
use crate::util::{level_to_score, natural_death_coins};
use crate::velocity::Velocity;
use arrayvec::ArrayVec;
use common_util::angle::Angle;
use core_protocol::serde_util::{StrVisitor, U8Visitor};
use macros::EntityTypeData;
use rand::prelude::IteratorRandom;
use rand::{thread_rng, Rng};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

impl EntityType {
    /// Data returns the data associated with the entity type.
    #[inline]
    pub fn data(self) -> &'static EntityData {
        unsafe { Self::DATA.get_unchecked(self as usize) }
    }

    /// reduced lifespan returns a lifespan to start an entity's life at, so as to make it expire
    /// in desired_lifespan ticks
    pub fn reduced_lifespan(self, desired_lifespan: Ticks) -> Ticks {
        self.data().lifespan.saturating_sub(desired_lifespan)
    }

    /// can_spawn_as returns whether it is possible to 
    
    pub fn loot(self, score: u32, score_to_coins: bool) -> impl Iterator<Item = Self> + 'static {
        let data: &EntityData = self.data();

        debug_assert_eq!(data.kind, EntityKind::Boat);

        let coin_amount = if score_to_coins {
            natural_death_coins(score)
        } else {
            0
        };

        let mut rng = thread_rng();

        // Loot is based on the length of the boat.
        let loot_amount = (data.length * 0.25 * (rng.gen::<f32>() * 0.1 + 0.9)) as u32;

        let mut loot_table = ArrayVec::<Self, 4>::new();

        match data.sub_kind {
            EntitySubKind::Pirate => {
                loot_table.push(Self::Crate);
                loot_table.push(Self::Coin);
            }
            EntitySubKind::Tanker => {
                loot_table.push(Self::Scrap);
                loot_table.push(Self::Barrel);
            }
            _ => match self {
                Self::Olympias => loot_table.push(Self::Crate),
                _ => loot_table.push(Self::Scrap),
            },
        };

        (0..loot_amount)
            .map(move |_| {
                *loot_table
                    .iter()
                    .choose(&mut rng)
                    .expect("at least once loot table option")
            })
            .chain((0..coin_amount).map(|_| Self::Coin))
    }