[][src]Trait slice_dst::SliceDst

pub unsafe trait SliceDst {
    fn layout_for(len: usize) -> Layout;
fn retype(ptr: NonNull<[()]>) -> NonNull<Self>; }

A custom slice-based dynamically sized type.

Unless you are making a custom slice DST that needs to pack its length extremely well, then you should just use SliceWithHeader instead.

Required methods

fn layout_for(len: usize) -> Layout

Get the layout of the slice-containing type with the given slice length.

fn retype(ptr: NonNull<[()]>) -> NonNull<Self>

Add the type onto an untyped pointer.

This is used to add the type on during allocation. This function is required because otherwise Rust cannot guarantee that the metadata on both sides of the cast lines up.

Safety

The implementation must not dereference the input pointer. This function is safe because it must work for all input pointers, without asserting the pointer's validity of any kind, express or implied, including but not limited to the validities of alignment, fitness for dereferencing and nullity.

In practice, this means that the implementation should just be a pointer cast.

Loading content...

Implementors

impl<Header> SliceDst for StrWithHeader<Header>[src]

impl<Header, Item> SliceDst for SliceWithHeader<Header, Item>[src]

impl<T> SliceDst for [T][src]

Loading content...