mirror of
https://github.com/RGBCube/cstree
synced 2025-07-27 17:17:45 +00:00
implement Hash and Eq for ResolvedNode and ResolvedToken. (#63)
These simply forward to the impls for SyntaxNode and SyntaxToken respectivly.
This commit is contained in:
parent
1babdb03ee
commit
1080120348
2 changed files with 29 additions and 0 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
* Implement `Hash` and `Eq` for `ResolvedNode` and `ResolvedToken`
|
||||||
|
|
||||||
## `v0.12.0`
|
## `v0.12.0`
|
||||||
|
|
||||||
* Documentation has been improved in most areas, together with a switch to a more principled module structure that allows explicitly documenting submodules.
|
* Documentation has been improved in most areas, together with a switch to a more principled module structure that allows explicitly documenting submodules.
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt,
|
fmt,
|
||||||
|
hash::Hash,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
sync::Arc as StdArc,
|
sync::Arc as StdArc,
|
||||||
};
|
};
|
||||||
|
@ -65,6 +66,18 @@ impl<S: Syntax, D> DerefMut for ResolvedNode<S, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S: Syntax, D> PartialEq for ResolvedNode<S, D> {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.syntax == other.syntax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<S: Syntax, D> Eq for ResolvedNode<S, D> {}
|
||||||
|
impl<S: Syntax, D> Hash for ResolvedNode<S, D> {
|
||||||
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
self.syntax.hash(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Syntax tree token that is guaranteed to belong to a tree that contains an associated
|
/// Syntax tree token that is guaranteed to belong to a tree that contains an associated
|
||||||
/// [`Resolver`](lasso::Resolver).
|
/// [`Resolver`](lasso::Resolver).
|
||||||
/// # See also
|
/// # See also
|
||||||
|
@ -109,6 +122,18 @@ impl<S: Syntax, D> DerefMut for ResolvedToken<S, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S: Syntax, D> PartialEq for ResolvedToken<S, D> {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.syntax == other.syntax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<S: Syntax, D> Eq for ResolvedToken<S, D> {}
|
||||||
|
impl<S: Syntax, D> Hash for ResolvedToken<S, D> {
|
||||||
|
fn hash<H: std::hash::Hasher>(&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
|
/// 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.
|
/// [`Resolver`](lasso::Resolver), can be either a node or a token.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue