macro_rules! assert_same {
($left:expr, $right:expr $(,)?) => { ... };
($left:expr, $right:expr, $($arg:tt)+) => { ... };
}Expand description
Asserts that two values are structurally the same.
This macro does not require PartialEq - it uses Facet reflection to
compare values structurally. Both values must have the same type, which
enables type inference to flow between arguments.
For comparing values of different types (e.g., during migrations), use
assert_sameish! instead.
§Panics
Panics if the values are not structurally same, displaying a colored diff showing exactly what differs.
Also panics if either value contains an opaque type that cannot be inspected.
§Example
use facet::Facet;
use facet_assert::assert_same;
#[derive(Facet)]
struct Person {
name: String,
age: u32,
}
let a = Person { name: "Alice".into(), age: 30 };
let b = Person { name: "Alice".into(), age: 30 };
assert_same!(a, b);Type inference works naturally:
use facet_assert::assert_same;
let x: Option<Option<i32>> = Some(None);
assert_same!(x, Some(None)); // Type of Some(None) inferred from x