mirror of
https://github.com/mbilker/kbinxml-rs.git
synced 2026-09-10 03:25:14 -05:00
node: add attr_mut helper method
This commit is contained in:
@@ -150,6 +150,11 @@ impl Node {
|
||||
self.attributes.as_ref()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn attributes_mut(&mut self) -> Option<&mut IndexMap<String, String>> {
|
||||
self.attributes.as_mut()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn children(&self) -> Option<&Vec<Node>> {
|
||||
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<Value>) {
|
||||
(self.key, self.value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user