Add a debug_assert to Vec::set_len

This commit is contained in:
Scott McMurray 2018-12-14 21:41:18 -08:00
parent a16e1a781d
commit 1fd971c3b9

View File

@ -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;
}