Skip to content

Commit

Permalink
Rollup merge of rust-lang#57589 - scottmcm:vec-set_len-debug_assert, …
Browse files Browse the repository at this point in the history
…r=alexcrichton

Add a debug_assert to Vec::set_len

Following the precedent of rust-lang#52972, which found llogiq/bytecount#42.

(This may well make a test fail; let's see what Travis says.)
  • Loading branch information
Centril authored Jan 14, 2019
2 parents b03d414 + 1fd971c commit 8a62e39
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 8a62e39

Please sign in to comment.