Remove HashableExpr abstraction (#14057)

## Summary

It looks like `ComparableExpr` now implements `Hash` so we can just
remove this.
This commit is contained in:
Charlie Marsh 2024-11-02 16:28:35 -04:00 committed by GitHub
parent 35c6dfe481
commit 4a3eeeff86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 53 deletions

View file

@ -1,40 +0,0 @@
use std::hash::Hash;
use crate::Expr;
use crate::comparable::ComparableExpr;
/// Wrapper around `Expr` that implements `Hash` and `PartialEq`.
pub struct HashableExpr<'a>(&'a Expr);
impl Hash for HashableExpr<'_> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
let comparable = ComparableExpr::from(self.0);
comparable.hash(state);
}
}
impl PartialEq<Self> for HashableExpr<'_> {
fn eq(&self, other: &Self) -> bool {
let comparable = ComparableExpr::from(self.0);
comparable == ComparableExpr::from(other.0)
}
}
impl Eq for HashableExpr<'_> {}
impl<'a> From<&'a Expr> for HashableExpr<'a> {
fn from(expr: &'a Expr) -> Self {
Self(expr)
}
}
impl<'a> HashableExpr<'a> {
pub const fn from_expr(expr: &'a Expr) -> Self {
Self(expr)
}
pub const fn as_expr(&self) -> &'a Expr {
self.0
}
}

View file

@ -9,7 +9,6 @@ pub use nodes::*;
pub mod comparable;
pub mod docstrings;
mod expression;
pub mod hashable;
pub mod helpers;
pub mod identifier;
mod int;