Skip to content

Commit

Permalink
Implement PartialEq for ChildrenRenderer (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry authored Feb 4, 2020
1 parent ee4792c commit aedce8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ pub struct ChildrenRenderer<T> {
children: Vec<T>,
}

impl<T: PartialEq> PartialEq for ChildrenRenderer<T> {
fn eq(&self, other: &Self) -> bool {
self.children == other.children
}
}

impl<T> ChildrenRenderer<T>
where
T: Clone + Into<VNode>,
Expand Down
10 changes: 7 additions & 3 deletions src/virtual_dom/vnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,13 @@ impl fmt::Debug for VNode {
impl PartialEq for VNode {
fn eq(&self, other: &VNode) -> bool {
match (self, other) {
(VNode::VTag(vtag_a), VNode::VTag(vtag_b)) => vtag_a == vtag_b,
(VNode::VText(vtext_a), VNode::VText(vtext_b)) => vtext_a == vtext_b,
_ => false, // TODO: Implement other variants
(VNode::VTag(a), VNode::VTag(b)) => a == b,
(VNode::VText(a), VNode::VText(b)) => a == b,
(VNode::VList(a), VNode::VList(b)) => a == b,
(VNode::VRef(a), VNode::VRef(b)) => a == b,
// Need to improve PartialEq for VComp before enabling
(VNode::VComp(_), VNode::VComp(_)) => false,
_ => false,
}
}
}

0 comments on commit aedce8b

Please sign in to comment.