is-same 0.2.1

A trait for comparing object equality.
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented0 out of 3 items with examples
  • Size
  • Source code size: 15.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.12 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • tiffany352/is-same
    3 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tiffany352

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.0 to 0.0.
  • Referential equality is used to make comparisons more efficient. The library assumes that the contents of Rc<T> and Arc<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 is_same_derive::IsSame;

#[derive(IsSame)]
struct MyStruct {
    count: usize,
    ch: char,
    text: String,
}