datex_core/values/value/
equality.rs1use core::hash::{Hash, Hasher};
2
3use crate::{
4 traits::{structural_eq::StructuralEq, value_eq::ValueEq},
5 values::value::Value,
6};
7
8impl StructuralEq for Value {
11 fn structural_eq(&self, other: &Self) -> bool {
12 match (self, other) {
13 (Value::Core(core_self), Value::Core(core_other)) => {
14 core_self.structural_eq(core_other)
15 }
16 (Value::Native(native_self), Value::Native(native_other)) => {
17 native_self.structural_eq(native_other)
18 }
19 _ => {
20 todo!("Structural equality not implemented for these variants")
21 }
22 }
23 }
24}
25
26impl ValueEq for Value {
29 fn value_eq(&self, other: &Self) -> bool {
30 match (self, other) {
31 (Value::Core(core_self), Value::Core(core_other)) => {
33 core_self.value_eq(core_other)
34 }
35
36 (Value::Native(native_self), Value::Native(native_other)) => {
38 native_self.value_eq(native_other)
39 }
40
41 (Value::Core(_core_self), Value::Native(_native_other))
43 | (Value::Native(_native_other), Value::Core(_core_self)) => {
44 todo!()
45 }
47 }
48 }
49}
50
51impl PartialEq for Value {
52 fn eq(&self, other: &Self) -> bool {
53 match (self, other) {
54 (Value::Core(core_self), Value::Core(core_other)) => {
56 core_self.eq(core_other)
57 }
58
59 (Value::Native(native_self), Value::Native(native_other)) => {
61 native_self.eq(native_other)
62 }
63
64 (Value::Core(_core_self), Value::Native(_native_other))
66 | (Value::Native(_native_other), Value::Core(_core_self)) => {
67 todo!()
68 }
70 }
71 }
72}
73
74impl Eq for Value {}
75impl Hash for Value {
76 fn hash<H: Hasher>(&self, state: &mut H) {
77 match self {
78 Value::Core(core_self) => {
79 core_self.hash(state);
80 }
81 Value::Native(native_self) => {
82 native_self.datex_hash(state);
83 }
84 }
85 }
86}