Change error message of a failing `assert_eq!`
Rust Internals [Unofficial]
April 3, 2026
One option is to wrap the assert_eq! in a custom function, so that `let user_id = 10; let actual = "Alice B."; let expected = "Alice Baker";
assert_eq!(
actual, expected,
"User: {} has mismatched name. Expected {}, got {}",
user_id, expected, actual
);`
Discussion in the ATmosphere