Skip to content

Commit

Permalink
Add Eq trait to XmlElement.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Mar 8, 2024
1 parent faf1d72 commit 38689b9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/xml/xml_element.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::xml::XmlDocument;
use crate::xml::XmlWrapper;
use std::ops::DerefMut;
use std::sync::Arc;
use xml_doc::Element;

/// An [XmlElement] maintains a single thread-safe reference to an [Element] of a [Document].
Expand All @@ -16,6 +17,14 @@ pub struct XmlElement {
pub(super) element: Element,
}

impl PartialEq for XmlElement {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.document, &other.document) && self.element == other.element
}
}

impl Eq for XmlElement {}

impl XmlElement {
/// Wrap an existing [Element] as [XmlElement] in the context of the given [XmlDocument].
pub fn new_raw(document: XmlDocument, element: Element) -> XmlElement {
Expand Down

0 comments on commit 38689b9

Please sign in to comment.