mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
add Element::has_ns(&self, NS)
This commit is contained in:
parent
4546db95fc
commit
8af3e50311
1 changed files with 17 additions and 1 deletions
|
@ -263,6 +263,22 @@ impl Element {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn is<N: AsRef<str>, NS: AsRef<str>>(&self, name: N, namespace: NS) -> bool {
|
pub fn is<N: AsRef<str>, NS: AsRef<str>>(&self, name: N, namespace: NS) -> bool {
|
||||||
self.name == name.as_ref() &&
|
self.name == name.as_ref() &&
|
||||||
|
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<NS: AsRef<str>>(&self, namespace: NS) -> bool {
|
||||||
self.namespaces.has(&self.prefix, namespace)
|
self.namespaces.has(&self.prefix, namespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue