Function can_read_unaligned

Source
pub fn can_read_unaligned<T: ?Sized>(ptr: *const T) -> bool
Expand description

Checks that pointer ptr point to a valid value of type T.

For that, the pointer has to be a valid pointer according to crate::mem conditions 1, 2 and 3, and the value stored must respect the validity invariants for type T.

Note this function succeeds for unaligned pointers. See self::can_dereference if you also want to check pointer alignment.

This function will panic today if the pointer is not null, and it points to an unallocated or deallocated memory location. This is an existing Kani limitation. See https://github.com/model-checking/kani/issues/2690 for more details.