macro_rules! assert_debug_snap {
($actual:expr, $expected:expr) => { ... };
($actual:expr, $expected:expr,$($tail:tt)+) => { ... };
}Expand description
Asserts any types implementing Debug.
The macro formats actual and expected using {:#?} pretty-printing prior to comparison.
§Syntax
ⓘ
assert_debug_snap!(actual, expected);
assert_debug_snap!(actual, expected, "pattern" => "replacement");
assert_debug_snap!(actual, expected, [limit] "pattern" => "replacement");
assert_debug_snap!(actual, expected, rule1, rule2, ...);§Examples
Basic debug assertion:
use assert_snap::assert_debug_snap;
assert_debug_snap!(Some(42), Some(42));Debug assertion with redaction rules:
use assert_snap::assert_debug_snap;
#[derive(Debug)]
struct User {
name: String,
token: String,
}
let user = User { name: "Alice".into(), token: "secret_123".into() };
assert_debug_snap!(
user,
User {
name: "Alice".to_string(),
token: "****".to_string(),
},
"secret_123" => "****"
);