DSTify

Rust crate for safe construction of custom dynamically-sized types (DSTs). Heavily inspired by slice-dst.
slice DSTs
use Dstify;
use ;
dyn Trait DSTs
use Dstify;
use ;
DbgExtra {
line: 10,
column: 27,
dbg: Custom {
kind: Interrupted,
error: ":/",
},
}
Motivation
In some, arguably niche, use-cases it's more convenient to use a slice instead of a reference.
Using a DST doubles the size of a reference from 8 to 16 bytes (on 64-bit platforms), but removes the need for a lifetime annotation and saves one pointer indirection.
Creating a reference (wide/fat pointer) to a built-in type like str or [u8] is easy, but it becomes extremely hard and error-prone once we'd like to store additional fields.
From dynamically sized types in rust nomicon:
Currently the only properly supported way to create a custom DST is by making your type generic and performing an unsizing coercion
Another possiblity is to manually allocate the memory with proper size and alignment and emplace the field values at correct offsets.
That's what is happening behind the curtains of dstify.