Realloc Layout for Box<[MaybeUninit]>?

⚓ rust    📅 2025-05-30    👤 surdeus    👁️ 3      

surdeus

I'd like to take a Box<[MaybeUninit<T>]>, take the raw pointer out of it, and reallocate it. However, my specific concern is that the realloc method specifies that:

  • layout is the same layout that was used to allocate that block of memory

If the Box was created via new_uninit_slice, is it safe to assume that Layout::array::<T>(box.len()) is the correct Layout builder to use for reallocating?

1 post - 1 participant

Read full topic

🏷️ rust_feed