Skip to main content

Dst

Derive Macro Dst 

Source
#[derive(Dst)]
{
    // Attributes available to this derive:
    #[dst]
}
Expand description

Derive macro for the Dst trait.

The underlying DST must be the last field of the struct.

This derive also creates a new_unchecked function, which takes each of the fields in the struct as arguments, with the last field (the DST) being taken as a reference. This new_unchecked function is marked as unsafe as it doesn’t check any of the type’s interior invariants. The visibility of this generated function can be modified with the #[dst(new_unchecked_vis = ...)] attribute.

The path to the simple_dst crate can be modified with the #[dst(simple_dst_path = ...)] attribute.

If there are any type parameters with a ?Sized trait bound, those are assumed to be the type of the DST, so the Dst and CloneToUninit trait bounds will be added.