Clarify safety comment
This commit is contained in:
parent
4f808161bc
commit
777c853b4a
1 changed files with 2 additions and 0 deletions
|
@ -2144,6 +2144,8 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
let ptr = self.as_mut_ptr();
|
||||
// SAFETY:
|
||||
// - `ptr` is guaranteed to be valid for `self.len` elements
|
||||
// - but the allocation extends out to `self.buf.capacity()` elements, possibly
|
||||
// uninitialized
|
||||
let spare_ptr = unsafe { ptr.add(self.len) };
|
||||
let spare_ptr = spare_ptr.cast::<MaybeUninit<T>>();
|
||||
let spare_len = self.buf.capacity() - self.len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue