Skip to content

Commit 777c853

Browse files
committed
Clarify safety comment
1 parent 4f80816 commit 777c853

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/alloc/src/vec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2144,6 +2144,8 @@ impl<T, A: Allocator> Vec<T, A> {
21442144
let ptr = self.as_mut_ptr();
21452145
// SAFETY:
21462146
// - `ptr` is guaranteed to be valid for `self.len` elements
2147+
// - but the allocation extends out to `self.buf.capacity()` elements, possibly
2148+
// uninitialized
21472149
let spare_ptr = unsafe { ptr.add(self.len) };
21482150
let spare_ptr = spare_ptr.cast::<MaybeUninit<T>>();
21492151
let spare_len = self.buf.capacity() - self.len;

0 commit comments

Comments
 (0)