Macro similar_asserts::assert_serde_eq

source ยท
macro_rules! assert_serde_eq {
    ($left_label:ident: $left:expr, $right_label:ident: $right:expr $(,)?) => { ... };
    ($left_label:ident: $left:expr, $right_label:ident: $right:expr, $($arg:tt)*) => { ... };
    ($left:expr, $right:expr $(,)?) => { ... };
    ($left:expr, $right:expr, $($arg:tt)*) => { ... };
}
Expand description

Asserts that two expressions are equal to each other (using PartialEq) using Serialize for comparision.

On panic, this macro will print the values of the expressions with their serde Serialize representations rendered in the same format that std::fmt::Debug would with a colorized diff of the changes in the debug output.

Like assert!, this macro has a second form, where a custom panic message can be provided.

use similar_asserts::assert_serde_eq;
assert_serde_eq!((1..3).collect::<Vec<_>>(), vec![1, 2]);

This requires the serde feature.