2 releases
0.2.1 | Jul 10, 2021 |
---|---|
0.2.0 | Jul 8, 2021 |
0.1.0 |
|
#1182 in Procedural macros
8KB
60 lines
Easy Address Comparison
A set of macros to allow your types to be compared based on where they are stored in memory. This is useful when two instances of a type should not be considered equal unless they are literally the same instance.
With this crate, you can derive AddressEq
, AddressOrd
, or AddressHash
depending on your needs.
Usage
use address_cmp::AddressEq;
#[derive(AddressEq, Debug)]
struct A {
pub a: u8,
}
let a1 = A { a: 0 };
let a2 = A { a: 0 };
assert_ne!(a1, a2);
assert_eq!(a1, a1);
lib.rs
:
Easy Address Comparison
A set of macros to allow your types to be compared based on where they are stored in memory. This is useful when two instances of a type should not be considered equal unless they are literally the same instance.
With this crate, you can derive AddressEq
, AddressOrd
, or AddressHash
depending on your needs.
Usage
use address_cmp::AddressEq;
#[derive(AddressEq, Debug)]
struct A {
pub a: u8,
}
let a1 = A { a: 0 };
let a2 = A { a: 0 };
assert_ne!(a1, a2);
assert_eq!(a1, a1);
Dependencies
~1.5MB
~36K SLoC