Skip to content

Commit

Permalink
Add a debug_assert to Vec::set_len
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Jan 14, 2019
1 parent a16e1a7 commit 1fd971c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ impl<T> Vec<T> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn set_len(&mut self, new_len: usize) {
debug_assert!(new_len <= self.capacity());

self.len = new_len;
}

Expand Down

0 comments on commit 1fd971c

Please sign in to comment.