In light of @RalfJung's comment here:
The discussion quickly moved to
freeze
as that is usually the primitive people ask for here.arbitrary()
is compatible with what I laid out for inline asm blocks so I am confident it is compatible with the rest of the compiler.
Maybe we should do an informal poll as to whether people would prefer an API like:
fn arbitrary<T: FromBytes>() -> T;
or
fn freeze<T: FromBytes>(data: MaybeUninit<T>) -> T;
The difference being that freeze()
must preserve data that was already initialized.