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: rawmaster.rs
    path of file: ./repos/rustrogueliketutorial/chapter-72-textlayers/src/raws
    
    the code of the file until where you have to start completion: use std::collections::{HashMap, HashSet};
use specs::prelude::*;
use crate::components::*;
use super::{Raws, faction_structs::Reaction};
use crate::random_table::{MasterTable, RandomTable};
use crate::{attr_bonus, npc_hp, mana_at_level};
use regex::Regex;
use specs::saveload::{MarkedBuilder, SimpleMarker};

pub fn parse_dice_string(dice : &str) -> (i32, i32, i32) {
    lazy_static! {
        static ref DICE_RE : Regex = Regex::new(r"(\d+)d(\d+)([\+\-]\d+)?").unwrap();
    }
    let mut n_dice = 1;
    let mut die_type = 4;
    let mut die_bonus = 0;
    for cap in DICE_RE.captures_iter(dice) {
        if let Some(group) = cap.get(1) {
            n_dice = group.as_str().parse::<i32>().expect("Not a digit");
        }
        if let Some(group) = cap.get(2) {
            die_type = group.as_str().parse::<i32>().expect("Not a digit");
        }
        if let Some(group) = cap.get(3) {
            die_bonus = group.as_str
    
    fn build_traited_weapons(&mut self, items_to_build : &[NewMagicItem]) {
        items_to_build.iter().filter(|i| i.bonus > 0).for_each(|nmw| {
            for wt in self.raws.weapon_traits.iter() {
                let mut base_item_copy = self.build_base_magic_item(&nmw);
                if let Some(mut weapon) = base_item_copy.weapon.as_mut() {
                    base_item_copy.name = format!("{} {}", wt.name, base_item_copy.name);
                    if let Some(base_value) = base_item_copy.base_value.as_mut() {
                        *base_value *= 2.0;
                    }
                        weapon.proc_chance = Some(0.25);
                        weapon.proc_effects = Some(wt.effects.clone());

                    let real_name = base_item_copy.name.clone();
                    self.raws.items.push(base_item_copy);
                    self.item_index.insert(real_name.clone(), self.raws.items.len()-1);

                    self.raws.spawn_table.push(super::SpawnTableEntry{
                        name : real_name.clone(),
                        weight : 9 - i32::abs(nmw.bonus),
                        min_depth : 2 + i32::abs((nmw.bonus-1)*3),
                        max_depth : 100,
                        add_map_depth_to_weight : None
                    });
                }
            }
        });
    }