use lazy_static::lazy_static; use serde::Deserialize; use serde_yaml; use std::collections::HashMap; use std::string::String; trait MagicItem { fn name(&self) -> &str; } struct Sword { name: String, } struct Potion { name: String, } struct Scroll { name: String, } struct Ring { name: String, } struct RodStaffWand { name: String, } struct Misc { name: String, } struct ArmorShield { name: String, } struct MiscWeapon { name: String, } impl MagicItem for Sword {} impl MagicItem for Potion {} impl MagicItem for Scroll {} impl MagicItem for Ring {} impl MagicItem for RodStaffWand {} impl MagicItem for Misc {} impl MagicItem for ArmorShield {} impl MagicItem for MiscWeapon {} lazy_static! { pub static ref MAGIC_ITEMS: HashMap> = load_magic_items(); } // TODO: Is this actually needed? Is there a real race condition this is avoiding? fn load_magic_items() -> HashMap> { let yaml_data = include_str!("../data/rules/magic_items.yaml"); serde_yaml::from_str(yaml_data).expect("Failed to parse magic items YAML") items }