diff options
| author | troido <troido@protonmail.com> | 2020-03-04 19:47:00 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-03-04 19:47:00 +0100 |
| commit | 022e439a6677b9865b7a3287dbd197d86266f8ef (patch) | |
| tree | 00c8cd7c08fe29cf9f6652b0082f2b13617e426c /src/encyclopedia.rs | |
| parent | f8364fb636a8e9276939ae8523966b038388e4ff (diff) | |
implemented growth
Diffstat (limited to 'src/encyclopedia.rs')
| -rw-r--r-- | src/encyclopedia.rs | 12 |
1 files changed, 7 insertions, 5 deletions
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<Encyclopedia, &'static str> { + pub fn from_json(val: Value) -> Result<Encyclopedia> { 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<PreEntity, &'static str> { - let assemblage = self.items.get(&template.name).ok_or("unknown assemblage name")?; + pub fn construct(&self, template: &Template) -> Result<PreEntity> { + let assemblage = self.items.get(&template.name).ok_or(aerr!("unknown assemblage name"))?; assemblage.instantiate(template) } |
