Can I use:
If you mean that nobody can ever (safely) write anything to the
T bytes, then no. For example, with sufficient placement/RVO smarts,
let x: AlwaysUninit<String> = ("foo".into(), panic!()) not only writes a
x, it even cleans it up afterwards.
I only want to prevent reads via
If someone wants to do anything more complex to actually read or write to the bytes, they should be able to
Yeah, it is valid and the call will panic
MaybeUninit methods should compile down to a panic when its
T is uninhabited, which is true in this case.
Now this made me wonder… did we reach a decision on unhabitedness of
Now this made me wonder… did we reach a decision on unhabitedness of &!?
@gnzlbg I do not understand what you are trying to achieve
assume_init is unsafe so if you are worried about a safe wrapper, you can ignore it
I actually needed a type to express that something is always uninitialized
You said so from the start but it's not clear what that means or what you want it for (I know from discord you were thinking about manually adding padding to a type but what exactly do you intend to accomplish by "expressing" this?)
Its "explicit" padding for
repr(C) types, there is never a need to initialize that to anything, nor to try to
::assume_init it, so none of that is needed.
sounds like you just want a newtype around
no type will have a validity invariant "must be uninitialized"
and the safety invariant is up to you with a newtype
but I also cannot imagine a situation where uninitialized memory is okay but initialized memory is not
this includes padding
in which case plain
[MaybeUninit<u8>; N] would do it
@RalfJ I just ended with a wrapper
struct Padding<T>(MaybeUninit<T>); that does not expose the private field, has no