I can't seem to find an API to create a wide pointer from thin pointer.
Wide pointer is created like this:
Box::into_non_null(Box::new_uninit_slice(size))
Since size
is known from the context, I'd like to store NonNull<MaybeUninit<u8>>
rather than NonNull<[MaybeUninit<u8>]>
, however I can't seem to find a way to go back from thin pointer to the wide pointer and layout of wide pointer is unstable either.
I'm fine using Nighty and unstable features that are on track for stabilization.
The main reason for converting to wide pointer is to de-allocate it properly with Box::from_non_null()
, but maybe alternative would be to de-allocate memory behind thin pointer, though allocator API seems to be unstable without a clear timeline when it might possibly be stabilized, so I thought re-creating Box
might be easier somehow.