Update based on petrochenkov's review

This commit is contained in:
George Bateman 2023-11-18 10:50:47 +00:00
parent 661df4fd55
commit 58ea02e872
No known key found for this signature in database
GPG Key ID: C417AA9C4039EFCF

View File

@ -97,10 +97,11 @@ fn drop(&mut self) {
// SAFETY: Loop conditions ensure the index is in bounds.
unsafe {
let opt_payload_at =
(&val as *const Option<B>).byte_add(core::mem::offset_of!(Option<B>, Some.0));
let opt_payload_at: *const MaybeUninit<B> = (&val as *const Option<B>)
.byte_add(core::mem::offset_of!(Option<B>, Some.0))
.cast();
let dst = guard.array.as_mut_ptr().add(idx);
crate::ptr::copy_nonoverlapping(opt_payload_at.cast(), dst, 1);
crate::ptr::copy_nonoverlapping(opt_payload_at, dst, 1);
crate::mem::forget(val);
};