Vec::reserve_exact should not shrink

reserve_exact should not shrink according to documentation.
This commit is contained in:
Stepan Koltsov
2014-04-01 20:16:59 +00:00
parent b71c02e512
commit 08e95a87b8

View File

@@ -447,7 +447,7 @@ impl<T> Vec<T> {
/// assert_eq!(vec.capacity(), 11); /// assert_eq!(vec.capacity(), 11);
/// ``` /// ```
pub fn reserve_exact(&mut self, capacity: uint) { pub fn reserve_exact(&mut self, capacity: uint) {
if capacity >= self.len { if capacity > self.cap {
let size = capacity.checked_mul(&size_of::<T>()).expect("capacity overflow"); let size = capacity.checked_mul(&size_of::<T>()).expect("capacity overflow");
self.cap = capacity; self.cap = capacity;
unsafe { unsafe {