diff --git a/src/element.rs b/src/element.rs index 50b63cd..13c8baf 100644 --- a/src/element.rs +++ b/src/element.rs @@ -38,18 +38,23 @@ impl fmt::Debug for Element { for attr in &self.attributes { write!(fmt, " {}", attr)?; } - write!(fmt, ">")?; - for child in &self.children { - match *child { - Node::Element(ref e) => { - write!(fmt, "{:?}", e)?; - }, - Node::Text(ref s) => { - write!(fmt, "{}", s)?; - }, - } + if self.children.is_empty() { + write!(fmt, "/>")?; + } + else { + write!(fmt, ">")?; + for child in &self.children { + match *child { + Node::Element(ref e) => { + write!(fmt, "{:?}", e)?; + }, + Node::Text(ref s) => { + write!(fmt, "{}", s)?; + }, + } + } + write!(fmt, "", self.name)?; } - write!(fmt, "", self.name)?; Ok(()) } }