Function checked_size_of_raw

Source
pub fn checked_size_of_raw<T: MetaSized>(ptr: *const T) -> Option<usize>
Expand description

Compute the size of the val pointed to if it is safe to do so.

Returns None if:

  • An overflow occurs during the size computation.
  • The pointer’s alignment is not a power of two.
  • The computed size exceeds isize::MAX (the maximum safe Rust allocation size). TODO: Optimize this if T is sized.