Always-Equal
Always-Equal lets you wrap PartialEq
implementations around
things that cannot be compared, like a File
.
To use Always-Equal, put these two conditional use
statements in your module:
use AlwaysEqual;
use AlwaysEqual;
Then wrap AlwaysEqual
around anything that needs
PartialEq but can't possibly implement it:
use File;
use AlwaysEqual;
// In test code, you can create an empty wrapper using
// `testing_blank`, which is equal to any other wrapper:
let expected = MyStruct ;
# let my_file = open .unwrap ;
let actual = MyStruct ;
assert_eq! ;
This is implemented with Option
in test mode.
In production mode, wrappers are never equal to any other
wrapper, and the Option
is removed so that
sizeof::<AlwaysEqual <T>> () == sizeof::<T>
should be true.