This crate provides the IsSame trait, which is specifically for diffing immutable data that has been transformed. The trait differs from PartialEq in some important ways:
- Floating point values are compared by their bit patterns,
preventing NaN values from making a data structure permanently
compare as not equal to itself. This also lets you detect a value
changing from
-0.0to0.0. - Referential equality is used to make comparisons more efficient.
The library assumes that the contents of
Rc<T>andArc<T>are immutable and can't change, so they only need to be compared by their pointers.
There is also a is-same-derive crate which can automatically
derive an IsSame implementation for your structs:
use IsSame;