pub unsafe fn is_equal_raw(x: *const u8, y: *const u8, n: usize) -> boolExpand description
Compare n bytes at the given pointers for equality.
This returns true if and only if *x.add(i) == *y.add(i) for all
0 <= i < n.
§Inlining
This routine is marked inline(always). If you want to call this function
in a way that is not always inlined, you’ll need to wrap a call to it in
another function that is marked as inline(never) or just inline.
§Motivation
Why not use slice equality instead? Well, slice equality usually results in
a call out to the current platform’s libc which might not be inlineable
or have other overhead. This routine isn’t guaranteed to be a win, but it
might be in some cases.
§Safety
- Both
xandymust be valid for reads of up tonbytes. - Both
xandymust point to an initialized value. - Both
xandymust each point to an allocated object and must either be in bounds or at most one byte past the end of the allocated object.xandydo not need to point to the same allocated object, but they may. - Both
xandymust be derived from a pointer to their respective allocated objects. - The distance between
xandx+nmust not overflowisize. Similarly foryandy+n. - The distance being in bounds must not rely on “wrapping around” the address space.