From a23483cb001d6b8aa7a59151fb9fca3a876680b2 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Sun, 30 Jun 2024 20:26:40 +0100 Subject: [PATCH] implement Hash and Eq for ResolvedNode and ResolvedToken. These simply forward to the impls for SyntaxNode and SyntaxToken respectivly. --- cstree/src/syntax/resolved.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cstree/src/syntax/resolved.rs b/cstree/src/syntax/resolved.rs index 40e670e..500d611 100644 --- a/cstree/src/syntax/resolved.rs +++ b/cstree/src/syntax/resolved.rs @@ -5,6 +5,7 @@ use std::{ fmt, + hash::Hash, ops::{Deref, DerefMut}, sync::Arc as StdArc, }; @@ -65,6 +66,18 @@ impl DerefMut for ResolvedNode { } } +impl PartialEq for ResolvedNode { + fn eq(&self, other: &Self) -> bool { + self.syntax == other.syntax + } +} +impl Eq for ResolvedNode {} +impl Hash for ResolvedNode { + fn hash(&self, state: &mut H) { + self.syntax.hash(state); + } +} + /// Syntax tree token that is guaranteed to belong to a tree that contains an associated /// [`Resolver`](lasso::Resolver). /// # See also @@ -109,6 +122,18 @@ impl DerefMut for ResolvedToken { } } +impl PartialEq for ResolvedToken { + fn eq(&self, other: &Self) -> bool { + self.syntax == other.syntax + } +} +impl Eq for ResolvedToken {} +impl Hash for ResolvedToken { + fn hash(&self, state: &mut H) { + self.syntax.hash(state); + } +} + /// An element of the tree that is guaranteed to belong to a tree that contains an associated /// [`Resolver`](lasso::Resolver), can be either a node or a token. ///