Rust Specification
Compile-time classification of types according to Rust specification.
Classification Axes
RustSpec describes a type across the following axes:
Layout: representation stability.Size: statically sized, metadata-sized, or extern-type-like shape.Alignment: ABI alignment in bytes as atypenumunsigned integer.Trap: whether the value representation has trap values.Niche: stable, unstable, or absent niche value.
Layout
Describes total reachable (through pointer indirection) representation stability:
Stable: compiler-guaranteed representation.Unstable: representation is not guaranteed.
Size
Describes compile-time size and pointer metadata shape:
Sized<Zst>: compile-time known zero-sized type.Sized<NonZst>: compile-time known non-zero-sized type.MetaSized<SliceLike>: dynamically sized slice-like type.MetaSized<DynTraitLike>: dynamically sized trait-object-like type.ExternTypeLike: dynamically sized extern-type-like type.
Alignment
The ABI alignment in bytes as a power-of-two typenum value.
Trap
Describes total reachable (through pointer indirection) value-representation validity:
Robust: every bit pattern is valid.NonRobust: some bit patterns are trap/invalid values.
Niche
Describes whether and what kind of niche is available for the type:
WithoutNiche: no niche is available.WithNiche<Stable>: compiler-guaranteed niche.WithNiche<Unstable>: niche exists but is not guaranteed.
How to Use
Derive RustSpec for your types, then use its associated marker families as bounds when implementing other traits:
use disjoint_impls;
use ;
disjoint_impls!
const HEADER_OPTION_NEEDS_TAG: bool = NEEDS_TAG;