facet-assert: Structural Assertions
Same Values
Two values with identical content pass assert_same! — no PartialEq required.
Target Type
#[derive(Facet)] struct Config { host: String, port: u16, debug: bool, tags: Vec<String>, }
Success
Config {
host: "localhost",
port: 8080,
debug: true,
tags: Vec<String> [
"prod",
"api",
],
}
Cross-Type Comparison
Different type names (Config vs ConfigV2) with the same structure are considered "same". Useful for comparing DTOs across API versions or testing serialization roundtrips.
Target Type
#[derive(Facet)] struct Config { host: String, port: u16, debug: bool, tags: Vec<String>, }
Success
Config {
host: "localhost",
port: 8080,
debug: true,
tags: Vec<String> [
"prod",
],
}
Nested Structs
Nested structs are compared recursively, field by field.
Target Type
#[derive(Facet)] struct Person { name: String, age: u32, address: Address, } #[derive(Facet)] struct Address { street: String, city: String, }
Success
Person {
name: "Alice",
age: 30,
address: Address {
street: "123 Main St",
city: "Springfield",
},
}
Structural Diff
When values differ, you get a precise structural diff showing exactly which fields changed and at what path — not just a wall of red/green text.
Diff Output
.host:
- "localhost"
+ "prod.example.com"
.port:
- 8080
+ 443
.debug:
- true
+ false
.tags[1] (only in left):
- "api"
Vector Differences
Vector comparisons show exactly which indices differ, which elements were added, and which were removed.
Diff Output
[2]:
- 3
+ 99
[4] (only in left):
- 5