pub enum AsInitialized {}Expand description
The byte ranges initialized in T are also initialized in the referent of a
Ptr<T>.
Formally: uninitialized bytes may only be present in Ptr<T>’s referent
where they are guaranteed to be present in T. This is a dynamic property:
if, at a particular byte offset, a valid enum discriminant is set, the
subsequent bytes may only have uninitialized bytes as specified by the
corresponding enum.
Formally, given len = size_of_val_raw(ptr), at every byte offset, b, in
the range [0, len):
-
If, in any instance
t: Tof lengthlen, the byte at offsetbintis initialized, then the byte at offsetbwithin*ptrmust be initialized. -
Let
cbe the contents of the byte range[0, b)in*ptr. LetSbe the subset of valid instances ofTof lengthlenwhich containcin the offset range[0, b). If, in any instance oft: TinS, the byte at offsetbintis initialized, then the byte at offsetbin*ptrmust be initialized.Pragmatically, this means that if
*ptris guaranteed to contain an enum type at a particular offset, and the enum discriminant stored in*ptrcorresponds to a valid variant of that enum type, then it is guaranteed that the appropriate bytes of*ptrare initialized as defined by that variant’s bit validity (although note that the variant may contain another enum type, in which case the same rules apply depending on the state of its discriminant, and so on recursively).