Trait 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

  • Self and Rhs have no padding.
  • Self and Rhs have the same layout (size and alignment).
  • Neither Self nor Rhs have provenance, so integer comparisons are correct.
  • <Self as PartialEq<Rhs>>::{eq,ne} are equivalent to comparing the bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl BytewiseEq for Option<NonZero<i8>>

Source§

impl BytewiseEq for Option<NonZero<i16>>

Source§

impl BytewiseEq for Option<NonZero<i32>>

Source§

impl BytewiseEq for Option<NonZero<i64>>

Source§

impl BytewiseEq for Option<NonZero<i128>>

Source§

impl BytewiseEq for Option<NonZero<isize>>

Source§

impl BytewiseEq for Option<NonZero<u8>>

Source§

impl BytewiseEq for Option<NonZero<u16>>

Source§

impl BytewiseEq for Option<NonZero<u32>>

Source§

impl BytewiseEq for Option<NonZero<u64>>

Source§

impl BytewiseEq for Option<NonZero<u128>>

Source§

impl BytewiseEq for Option<NonZero<usize>>

Source§

impl BytewiseEq for Ordering

Source§

impl BytewiseEq for bool

Source§

impl BytewiseEq for char

Source§

impl BytewiseEq for i8

Source§

impl BytewiseEq for i16

Source§

impl BytewiseEq for i32

Source§

impl BytewiseEq for i64

Source§

impl BytewiseEq for i128

Source§

impl BytewiseEq for isize

Source§

impl BytewiseEq for u8

Source§

impl BytewiseEq for u16

Source§

impl BytewiseEq for u32

Source§

impl BytewiseEq for u64

Source§

impl BytewiseEq for u128

Source§

impl BytewiseEq for usize

Source§

impl BytewiseEq for NonZero<i8>

Source§

impl BytewiseEq for NonZero<i16>

Source§

impl BytewiseEq for NonZero<i32>

Source§

impl BytewiseEq for NonZero<i64>

Source§

impl BytewiseEq for NonZero<i128>

Source§

impl BytewiseEq for NonZero<isize>

Source§

impl BytewiseEq for NonZero<u8>

Source§

impl BytewiseEq for NonZero<u16>

Source§

impl BytewiseEq for NonZero<u32>

Source§

impl BytewiseEq for NonZero<u64>

Source§

impl BytewiseEq for NonZero<u128>

Source§

impl BytewiseEq for NonZero<usize>

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 0]> for [T; 0]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 1]> for [T; 1]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 2]> for [T; 2]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 3]> for [T; 3]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 4]> for [T; 4]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 6]> for [T; 6]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 8]> for [T; 8]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 12]> for [T; 12]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 16]> for [T; 16]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 24]> for [T; 24]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 32]> for [T; 32]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 48]> for [T; 48]

Source§

impl<T: BytewiseEq<U>, U> BytewiseEq<[U; 64]> for [T; 64]