feat: add with_opt_attribute convenince function to handle options
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user