A pointer created from an arbitrary arithmetic expression may designate an invalid address,
including an address that does not point to a valid object, an address that points to an
object of the wrong type, or an address that is not properly aligned. Use of such a pointer
to access memory will result in undefined behavior.
The as operator also does not check that the size of the source operand is the same as
the size of a pointer, which may lead to unexpected results if the address computation was
originally performed in a differently-sized address space.
While as can notionally be used to create a null pointer, the functions
core::ptr::null and core::ptr::null_mut are the more idiomatic way to do this.
|