Derive Macro ByteEq

#[derive(ByteEq)]
{
    // Attributes available to this derive:
    #[zerocopy]
}
Expand description

Derives optimized PartialEq and Eq implementations.

This derive can be applied to structs and enums implementing both Immutable and IntoBytes; e.g.:

#[derive(ByteEq, Immutable, IntoBytes)]
#[repr(C)]
struct MyStruct {
    ...
}

#[derive(ByteEq, Immutable, IntoBytes)]
#[repr(u8)]
enum MyEnum {
    ...
}

The standard library’s derive(Eq, PartialEq) computes equality by individually comparing each field. Instead, the implementation of PartialEq::eq emitted by derive(ByteHash) converts the entirey of self and other to byte slices and compares those slices for equality. This may have performance advantages.