From 022e439a6677b9865b7a3287dbd197d86266f8ef Mon Sep 17 00:00:00 2001 From: troido Date: Wed, 4 Mar 2020 19:47:00 +0100 Subject: implemented growth --- src/encyclopedia.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/encyclopedia.rs') diff --git a/src/encyclopedia.rs b/src/encyclopedia.rs index 7b40373..8de5424 100644 --- a/src/encyclopedia.rs +++ b/src/encyclopedia.rs @@ -5,7 +5,9 @@ use crate::{ assemblage::Assemblage, componentwrapper::PreEntity, Template, - template::EntityType + template::EntityType, + Result, + aerr }; #[derive(Default, Clone)] @@ -15,16 +17,16 @@ pub struct Encyclopedia { impl Encyclopedia { - pub fn from_json(val: Value) -> Result { + pub fn from_json(val: Value) -> Result { let mut items = HashMap::new(); - for (k, v) in val.as_object().ok_or("encyclopedia not a json object")?.into_iter() { + for (k, v) in val.as_object().ok_or(aerr!("encyclopedia not a json object"))?.into_iter() { items.insert(EntityType(k.clone()), Assemblage::from_json(v)?); } Ok(Encyclopedia{items}) } - pub fn construct(&self, template: &Template) -> Result { - let assemblage = self.items.get(&template.name).ok_or("unknown assemblage name")?; + pub fn construct(&self, template: &Template) -> Result { + let assemblage = self.items.get(&template.name).ok_or(aerr!("unknown assemblage name"))?; assemblage.instantiate(template) } -- cgit