Skip to content

Commit 153a916

Browse files
committed
add debug asserts
1 parent 0c443cf commit 153a916

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/alloc/src/vec.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,6 +2947,8 @@ impl<T> IntoIter<T> {
29472947
/// * `offset == 0` is always valid
29482948
/// * `offset` must be positive
29492949
unsafe fn into_vec_with_uninit_prefix(self, offset: isize) -> Vec<T> {
2950+
debug_assert!(offset > 0);
2951+
debug_assert!(offset as usize + self.len() <= self.cap);
29502952
let dst = unsafe { self.buf.as_ptr().offset(offset) };
29512953
if self.ptr != dst as *const _ {
29522954
unsafe { ptr::copy(self.ptr, dst, self.len()) }

0 commit comments

Comments
 (0)