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 6, 2019
1 parent 19de501 commit 3cfc46a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib.rs
Expand Up @@ -664,6 +664,8 @@ impl<A: Array> SmallVec<A> {
if unspilled {
return;
}
} else {
return;
}
deallocate(ptr, cap);
}
Expand Down Expand Up @@ -2311,4 +2313,18 @@ mod tests {
let decoded: SmallVec<[i32; 2]> = deserialize(&encoded).unwrap();
assert_eq!(small_vec, decoded);
}

#[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 3cfc46a

Please sign in to comment.