Trait core::cmp::bytewise::BytewiseEq
source · pub(crate) unsafe trait BytewiseEq<Rhs = Self>: PartialEq<Rhs> + Sized { }Expand description
Types where == & != are equivalent to comparing their underlying bytes.
Importantly, this means no floating-point types, as those have different
byte representations (like -0 and +0) which compare as the same.
Since byte arrays are Eq, that implies that these types are probably also
Eq, but that’s not technically required to use this trait.
Rhs is de facto always Self, but the separate parameter is important
to avoid the specializing impl repeats parameter error when consuming this.
Safety
SelfandRhshave no padding.SelfandRhshave the same layout (size and alignment).- Neither
SelfnorRhshave provenance, so integer comparisons are correct. <Self as PartialEq<Rhs>>::{eq,ne}are equivalent to comparing the bytes.