summaryrefslogtreecommitdiff
path: root/src/template.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-05-12 21:51:37 +0200
committertroido <troido@protonmail.com>2020-05-12 21:51:37 +0200
commit1b380b31f50035f10f651e220effe8a2970c0fd5 (patch)
tree5a25b839a4ee70ba96f7f096161ea59c08842492 /src/template.rs
parent6c5b15758fbceef7987b40ee50a71ddc9624372d (diff)
removed 'substitute' part of encyclopedia
Diffstat (limited to 'src/template.rs')
-rw-r--r--src/template.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/template.rs b/src/template.rs
index 6b2dec3..0ac03cd 100644
--- a/src/template.rs
+++ b/src/template.rs
@@ -12,7 +12,7 @@ use crate::{
pub struct EntityType(pub String);
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
-enum SaveOption {
+pub enum SaveOption {
Default,
False,
Always
@@ -23,7 +23,7 @@ pub struct Template {
pub name: EntityType,
pub args: Vec<Parameter>,
pub kwargs: HashMap<String, Parameter>,
- save: SaveOption,
+ pub save: SaveOption,
}
@@ -65,6 +65,16 @@ impl Template {
self
}
+ pub fn merge(mut self, other: Template) -> Self {
+ if self.save == SaveOption::Default {
+ self.save = other.save;
+ }
+ for (key, value) in other.kwargs {
+ self.kwargs.entry(key).or_insert(value);
+ }
+ self
+ }
+
pub fn from_json(v: &Value) -> PResult<Template> {
let val = match v {
Value::String(s) => json!({"type": s}),