Skip to content

Commit 451b749

Browse files
ericktalexcrichton
authored andcommitted
collections: Fix conditional when reserving extra vec space
1 parent e7adb84 commit 451b749

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl<T> Vec<T> {
496496
/// assert!(vec.capacity() >= 10);
497497
/// ```
498498
pub fn reserve(&mut self, capacity: uint) {
499-
if capacity >= self.len {
499+
if capacity > self.cap {
500500
self.reserve_exact(num::next_power_of_two(capacity))
501501
}
502502
}

0 commit comments

Comments
 (0)