datex_core/shared_values/shared_container/
equality.rs1use crate::{
2 shared_values::{SharedContainer, internal_traits::_ExposeRcInternal},
3 traits::{
4 identity::Identity, structural_eq::StructuralEq, value_eq::ValueEq,
5 },
6};
7use alloc::rc::Rc;
8use core::hash::{Hash, Hasher};
9
10impl Eq for SharedContainer {}
11
12impl PartialEq for SharedContainer {
14 fn eq(&self, other: &Self) -> bool {
15 self.identical(other)
16 }
17}
18
19impl Hash for SharedContainer {
20 fn hash<H: Hasher>(&self, state: &mut H) {
21 let ptr = Rc::as_ptr(self.get_rc_internal());
22 ptr.hash(state); }
24}
25
26impl StructuralEq for SharedContainer {
27 fn structural_eq(&self, other: &Self) -> bool {
28 self.inner()
29 .base_shared_container()
30 .value_container()
31 .structural_eq(
32 other.inner().base_shared_container().value_container(),
33 )
34 }
35}
36
37impl ValueEq for SharedContainer {
38 fn value_eq(&self, other: &Self) -> bool {
39 self.inner()
40 .base_shared_container()
41 .value_container()
42 .value_eq(other.inner().base_shared_container().value_container())
43 }
44}