From 03243f32881e00b803741c38cffff8b30e42e7dc Mon Sep 17 00:00:00 2001 From: davidemazzocchi Date: Wed, 8 Oct 2025 16:51:06 +0200 Subject: [PATCH] feat: add with_opt_attribute convenince function to handle options --- 01.workspace/heave/src/str/entity.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/01.workspace/heave/src/str/entity.rs b/01.workspace/heave/src/str/entity.rs index 64a3eb9..53e4376 100644 --- a/01.workspace/heave/src/str/entity.rs +++ b/01.workspace/heave/src/str/entity.rs @@ -35,6 +35,13 @@ impl O { self.attributes.insert(attribute.id.clone(), attribute); self } + pub fn with_opt_attribute(mut self, id: &str, value: Option>) -> Self { + if let Some(value) = value { + let attribute = Attribute::new(id, value); + self.attributes.insert(attribute.id.clone(), attribute); + } + self + } pub fn value_of(&self, id: &str) -> Option<&Value> { let attribute = self.attributes.get(id); match attribute {