pub unsafe trait Uninit: Sized { }
Expand description
Types that may be constructed in an uninitialized state.
§Safety
It must be safe to construct the type in an uninitialized state. This is true if your type only contains:
- Zero-sized types.
MaybeUninit
itself.- Other
Uninit
types.
Note that the type must be inhabited. Implementing this trait for
uninhabited types such as !
and enum {}
would cause undefined
behavior upon creation.
Furthermore, care should be taken to not implement this trait for types
that have creation invariants. GhostToken
from GhostCell, for example,
while being a zero-sized type, is unsound to create from nothing.
If this invariant is not upheld, undefined behavior is likely to occur.
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.