PointerMetadata

Trait PointerMetadata 

Source
#[doc(hidden)] pub trait PointerMetadata:
    Copy
    + Eq
    + Debug {
    // Required methods
    fn from_elem_count(elems: usize) -> Self;
    fn size_for_metadata(self, layout: DstLayout) -> Option<usize>;
}
Expand description

The metadata associated with a KnownLayout type.

Required Methods§

Source

fn from_elem_count(elems: usize) -> Self

Constructs a Self from an element count.

If Self = (), this returns (). If Self = usize, this returns elems. No other types are currently supported.

Source

fn size_for_metadata(self, layout: DstLayout) -> Option<usize>

Computes the size of the object with the given layout and pointer metadata.

§Panics

If Self = (), layout must describe a sized type. If Self = usize, layout must describe a slice DST. Otherwise, size_for_metadata may panic.

§Safety

size_for_metadata promises to only return None if the resulting size would not fit in a usize.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl PointerMetadata for ()

Source§

impl PointerMetadata for usize

Implementors§