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 7, 2019
1 parent f96322b commit b28c6b3
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 @@ -2329,4 +2331,18 @@ mod tests {
v.push(4);
assert_eq!(v[..], [4]);
}

#[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 b28c6b3

Please sign in to comment.