Crate similar_asserts
source · [−]Expand description
similar-asserts is a crate that enhances the default assertion
experience by using similar for diffing.
On failed assertions it renders out a colorized diff to the terminal.
It comes with a handful of macros to replace std::assert_eq! with:
assert_eq!: diffsDebugon assertion failure.assert_serde_eq!: diffsSerializeon assertion failure.assert_str_eq!: compares both sides to strings and diffs those on failure.

Usage
use similar_asserts::assert_eq;
assert_eq!((1..3).collect::<Vec<_>>(), vec![1, 2]);Optionally the assertion macros also let you “name” the left and right side which will produce slightly more explicit output:
use similar_asserts::assert_eq;
assert_eq!(expected: vec![1, 2], actual: (1..3).collect::<Vec<_>>());Feature Flags
unicodeenable improved character matching (enabled by default)serdeturns on support for serde.