Skip to content

Commit cb10def

Browse files
committed
feat: impelment PartialEq and Eq for tree_sitter::Node
1 parent 8740992 commit cb10def

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

crates/postgresql-cst-parser/src/tree_sitter.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Tree {
4747
}
4848
}
4949

50-
pub fn root_node(&self) -> Node {
50+
pub fn root_node(&self) -> Node<'_> {
5151
Node {
5252
input: &self.src,
5353
range_map: Rc::clone(&self.range_map),
@@ -63,6 +63,14 @@ pub struct Node<'a> {
6363
pub node_or_token: NodeOrToken<'a>,
6464
}
6565

66+
impl<'a> PartialEq for Node<'a> {
67+
fn eq(&self, other: &Self) -> bool {
68+
self.node_or_token == other.node_or_token
69+
}
70+
}
71+
72+
impl<'a> Eq for Node<'a> {}
73+
6674
#[derive(Debug, Clone)]
6775
pub struct TreeCursor<'a> {
6876
pub input: &'a str,

0 commit comments

Comments
 (0)