Description
The Safety section currently uses a number of non-standard terms and is rather small. The biggest pain point might be:
- Memory blocks returned from an allocator must point to valid memory and retain their validity until the instance and all of its clones are dropped,
This leaves a number of important requirements open. The term 'valid memory' isn't used anywhere else in the standard library documentation. It isn't even decided what the validity of a [u8]
requires (see ucg-71). The wording doesn't make it clear that the caller must be allowed to write any contents to it, including uninitialized memory. It should also be mentioned that no other reference pointing to the memory region must be used while the block is allocated. Both of these requirements are already necessary to implement Box
in terms of an AllocRef
impl.
In comparison, MaybeUninit
is arguably simpler and safer to use and has a far more extensive documentation.