check_sameish

Function check_sameish 

Source
pub fn check_sameish<'f, T: Facet<'f>, U: Facet<'f>>(
    left: &T,
    right: &U,
) -> Sameness
Expand description

Check if two Facet values of potentially different types are structurally the same.

Unlike check_same, this allows comparing values of different types. Two values are “sameish” if they have the same structure and values, even if they have different type names.

Note: Because the two arguments can have different types, the compiler cannot infer types from one side to the other. If you get type inference errors, either add type annotations or use check_same instead.

§Example

use facet::Facet;
use facet_assert::check_sameish;

#[derive(Facet)]
struct PersonV1 { name: String }

#[derive(Facet)]
struct PersonV2 { name: String }

let old = PersonV1 { name: "Alice".into() };
let new = PersonV2 { name: "Alice".into() };
check_sameish(&old, &new); // Different types, same structure