Function std::intrinsics::raw_eq

const: unstable· source · []
pub unsafe extern "rust-intrinsic" fn raw_eq<T>(a: &T, b: &T) -> bool
🔬 This is a nightly-only experimental API. (core_intrinsics)
Expand description

Determines whether the raw bytes of the two values are equal.

This is particularly handy for arrays, since it allows things like just comparing i96s instead of forcing allocas for [6 x i16].

Above some backend-decided threshold this will emit calls to memcmp, like slice equality does, instead of causing massive code size.

Safety

It’s UB to call this if any of the bytes in *a or *b are uninitialized. Note that this is a stricter criterion than just the values being fully-initialized: if T has padding, it’s UB to call this intrinsic.

(The implementation is allowed to branch on the results of comparisons, which is UB if any of their inputs are undef.)