Derive Macro address_cmp::AddressEq[][src]

#[derive(AddressEq)]
Expand description

Derives PartialEq and Eq based on memory addresses.

By deriving AddressEq, the PartialEq and Eq traits will automatically be implemented for the given type. The implementations will use a given instance’s address in memory in when checking equality.

use address_cmp::AddressEq;

#[derive(AddressEq, Debug)]
struct Person {
    pub age: u8,
    pub name: String,
}

let p1 = Person { age: 22, name: "Mercutio".into() };
let p2 = Person { age: 22, name: "Mercutio".into() };

assert_ne!(p1, p2);
assert_eq!(p1, p1);