diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2018-12-14 21:41:18 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2019-01-13 22:40:25 -0800 |
| commit | 1fd971c3b97bc1f01740a552aeb3d23b6ed194f5 (patch) | |
| tree | 11cac072b2ee22aa81c4096bbc8f5fe2cee4ede6 /src/liballoc | |
| parent | a16e1a781de15f276d558f542ee40b45a0eab143 (diff) | |
| download | rust-1fd971c3b97bc1f01740a552aeb3d23b6ed194f5.tar.gz rust-1fd971c3b97bc1f01740a552aeb3d23b6ed194f5.zip | |
Add a debug_assert to Vec::set_len
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/vec.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index e1c5ab15bb5..ba3b3dfbfc2 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -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; } |
