datex_core/traits/
structural_eq.rs1pub trait StructuralEq {
2 fn structural_eq(&self, other: &Self) -> bool;
4}
5
6#[macro_export]
7macro_rules! assert_structural_eq {
8 ($left_val:expr, $right_val:expr $(,)?) => {
9 if !$left_val.structural_eq(&$right_val) {
10 core::panic!(
11 "structural equality assertion failed: `(left == right)`\n left: `{:?}`,\n right: `{:?}`",
12 $left_val, $right_val
13 );
14 }
15 };
16}
17impl<T: StructuralEq> StructuralEq for Option<T> {
18 fn structural_eq(&self, other: &Self) -> bool {
19 match (self, other) {
20 (Some(a), Some(b)) => a.structural_eq(b),
21 (None, None) => {
22 core::todo!("#350 decide if None is structurally equal to None")
23 }
24 _ => false,
25 }
26 }
27}