Skip to content

Commit

Permalink
Fix using grow to the same size.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Jun 8, 2019
1 parent 88b62b6 commit 4ba0d0f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib.rs
Expand Up @@ -665,6 +665,8 @@ impl<A: Array> SmallVec<A> {
if unspilled {
return;
}
} else {
return;
}
deallocate(ptr, cap);
}
Expand Down Expand Up @@ -2341,4 +2343,18 @@ mod tests {
v.extend(it);
assert_eq!(v[..], ['a']);
}

#[test]
fn grow_spilled_same_size() {
let mut v: SmallVec<[u8; 2]> = SmallVec::new();
v.push(0);
v.push(1);
v.push(2);
assert!(v.spilled());
assert_eq!(v.capacity(), 4);
// grow with the same capacity
v.grow(4);
assert_eq!(v.capacity(), 4);
assert_eq!(v[..], [0, 1, 2]);
}
}

0 comments on commit 4ba0d0f

Please sign in to comment.