Function ptr_meta::metadata

source ·
pub const fn metadata<T: Pointee + ?Sized>(
    ptr: *const T,
) -> <T as Pointee>::Metadata
Expand description

Returns the metadata of the given pointer.

*mut T, &T, and &mut T can all be passed directly to this function as they implicitly coerce to *const T.

§Example

// String slices have pointer metadata equal to their size in bytes
assert_eq!(ptr_meta::metadata("foo"), 3_usize);