diff --git a/01.workspace/heave/src/str/attribute.rs b/01.workspace/heave/src/str/attribute.rs index 7754589..d7c9afd 100644 --- a/01.workspace/heave/src/str/attribute.rs +++ b/01.workspace/heave/src/str/attribute.rs @@ -5,3 +5,12 @@ pub struct O { pub id: String, pub value: Value, } + +impl O { + pub fn new(id: &str, value: Value) -> Self { + Self { + id: String::from(id), + value, + } + } +} diff --git a/01.workspace/heave/src/str/entity.rs b/01.workspace/heave/src/str/entity.rs index aac1e73..e61f730 100644 --- a/01.workspace/heave/src/str/entity.rs +++ b/01.workspace/heave/src/str/entity.rs @@ -5,3 +5,17 @@ pub struct O { pub class: String, pub attributes: std::collections::HashMap, } + +impl O { + pub fn new(class: &str) -> Self { + Self { + class: String::from(class), + attributes: std::collections::HashMap::new(), + } + } + pub fn with_attribute(mut self, id: &str, value: Value) -> Self { + let attribute = Attribute::new(id, value); + self.attributes.insert(attribute.id.clone(), attribute); + self + } +}