From 8af3e50311c808fb65c0dcd051ab8a3a1678951a Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 19 Aug 2017 01:17:45 +0200 Subject: [PATCH] add Element::has_ns(&self, NS) --- src/element.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/element.rs b/src/element.rs index e0aebf86..1cbdd272 100644 --- a/src/element.rs +++ b/src/element.rs @@ -263,7 +263,23 @@ impl Element { /// ``` pub fn is, NS: AsRef>(&self, name: N, namespace: NS) -> bool { self.name == name.as_ref() && - self.namespaces.has(&self.prefix, namespace) + self.has_ns(namespace) + } + + /// Returns whether the element has the given namespace. + /// + /// # Examples + /// + /// ```rust + /// use minidom::Element; + /// + /// let elem = Element::builder("name").ns("namespace").build(); + /// + /// assert_eq!(elem.has_ns("namespace"), true); + /// assert_eq!(elem.has_ns("wrong"), false); + /// ``` + pub fn has_ns>(&self, namespace: NS) -> bool { + self.namespaces.has(&self.prefix, namespace) } /// Parse a document from an `EventReader`.