use core::hash::{Hash, Hasher};
use crate::{
traits::{structural_eq::StructuralEq, value_eq::ValueEq},
values::value::Value,
};
impl StructuralEq for Value {
fn structural_eq(&self, other: &Self) -> bool {
match (self, other) {
(Value::Core(core_self), Value::Core(core_other)) => {
core_self.structural_eq(core_other)
}
(Value::Native(native_self), Value::Native(native_other)) => {
native_self.structural_eq(native_other)
}
_ => {
todo!("Structural equality not implemented for these variants")
}
}
}
}
impl ValueEq for Value {
fn value_eq(&self, other: &Self) -> bool {
match (self, other) {
(Value::Core(core_self), Value::Core(core_other)) => {
core_self.value_eq(core_other)
}
(Value::Native(native_self), Value::Native(native_other)) => {
native_self.value_eq(native_other)
}
(Value::Core(_core_self), Value::Native(_native_other))
| (Value::Native(_native_other), Value::Core(_core_self)) => {
todo!()
}
}
}
}
impl PartialEq for Value {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Value::Core(core_self), Value::Core(core_other)) => {
core_self.eq(core_other)
}
(Value::Native(native_self), Value::Native(native_other)) => {
native_self.eq(native_other)
}
(Value::Core(_core_self), Value::Native(_native_other))
| (Value::Native(_native_other), Value::Core(_core_self)) => {
todo!()
}
}
}
}
impl Eq for Value {}
impl Hash for Value {
fn hash<H: Hasher>(&self, state: &mut H) {
match self {
Value::Core(core_self) => {
core_self.hash(state);
}
Value::Native(native_self) => {
native_self.datex_hash(state);
}
}
}
}