Vec::reserve_exact should not shrink
reserve_exact should not shrink according to documentation.
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user