diff --git a/src/node/mod.rs b/src/node/mod.rs index 5b55863..a8cb448 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -150,6 +150,11 @@ impl Node { self.attributes.as_ref() } + #[inline] + pub fn attributes_mut(&mut self) -> Option<&mut IndexMap> { + self.attributes.as_mut() + } + #[inline] pub fn children(&self) -> Option<&Vec> { self.children.as_ref() @@ -181,6 +186,12 @@ impl Node { }) } + pub fn attr_mut(&mut self, key: &str) -> Option<&mut String> { + self.attributes_mut().and_then(|attributes| { + attributes.get_mut(key) + }) + } + pub fn into_key_and_value(self) -> (String, Option) { (self.key, self.value) }