From 7d2699e08e36d28997f573ca3e76ee09cabe9669 Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 13 Aug 2017 02:28:44 +0200 Subject: [PATCH] NamespaceSet::set_parent(): don't require a full Element by passing just a reference to a NamespaceSet we could reuse this for xmlns elision in the serialization code. --- src/element.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/element.rs b/src/element.rs index 8623131..1a9aeb8 100644 --- a/src/element.rs +++ b/src/element.rs @@ -136,9 +136,9 @@ impl NamespaceSet { } } - fn set_parent(&self, parent: &Element) { + fn set_parent(&self, parent: Rc) { let mut parent_ns = self.parent.borrow_mut(); - let new_set = parent.namespaces.clone(); + let new_set = parent; *parent_ns = Some(new_set); } @@ -579,7 +579,7 @@ impl Element { /// assert_eq!(child.name(), "new"); /// ``` pub fn append_child(&mut self, child: Element) -> &mut Element { - child.namespaces.set_parent(&self); + child.namespaces.set_parent(self.namespaces.clone()); self.children.push(Node::Element(child)); if let Node::Element(ref mut cld) = *self.children.last_mut().unwrap() { @@ -882,7 +882,7 @@ impl ElementBuilder { // Propagate namespaces for node in &element.children { if let Node::Element(ref e) = *node { - e.namespaces.set_parent(&element); + e.namespaces.set_parent(element.namespaces.clone()); } }