pub unsafe trait InitialisationStatus: InitialisationStatusSealed {
type InvertInitialisationStatus: InitialisationStatus;
const IS_INIT: bool;
const IS_UNINIT: bool = _;
}
Expand description
Compile-time known value for if the current type encodes initialised or not
This can be used for example for a state that has a default variant, where
it doesn’t matter if it has been set or not before buliding. However, we
cannot call assume_init
on uninitialised values! We can therefore use this
value to check if something has been initialised (and the type changed to
reflect it), and act accordingly.
Since the value is a constant known at compile time, the optimiser is very likely able to elide the check.
§Safety
Implementing this trait is a promise that your
IS_INIT
value is actually reflective of initialisation state, and
InvertInitialisationStatus
is too, assuming the types have been used correctly.
Required Associated Constants§
Provided Associated Constants§
Required Associated Types§
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.