feat: add with_opt_attribute convenince function to handle options

This commit is contained in:
2025-10-08 16:51:06 +02:00
parent 8f189f0640
commit 03243f3288

View File

@@ -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<impl Into<Value>>) -> 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 {