Expand description
Safe abstractions around pointing at uninitialized memory without references.
This solves two issues beyond the standard library: Firstly, MaybeUninit does not permitted
unsized types. Secondly, a strict interpretation of pointer provenance implies that once a
reference is created our access is restricted the memory referred to in it. This spoils our
access to any memory in a potential tail of the allocation, which is wasteful.
It is potentially UB to have references to uninitialized memory even if such a reference is not ‘used’ in any particular manner. See the discussion of the unsafe working group.
TODO: In some next version we’d like to switch to &'a UnsafeCell<MaybeUninit<T>> here, or
even replace the UnsafeCell once we’ve replace the view attribute in Uninit. But alas we’re
not permitted to have an unsized parameter to MaybeUninit.
More work using unsized type parameter would in particular make it redundant to store the
length as we could refer to memory with a wrapper Byte(u8) and the T = [Byte] instantiation
for the type parameter of Uninit/UninitView. Storing additional bytes would be a wrapper
around the main interface.
Structs§
- Uninit
- Points to an uninitialized place but would otherwise be a valid reference.
- Uninit
View - A non-mutable view on a region used in an
Uninit.