diff --git a/lib.rs b/lib.rs index 5af32ba..103454a 100644 --- a/lib.rs +++ b/lib.rs @@ -664,6 +664,8 @@ impl SmallVec { if unspilled { return; } + } else { + return; } deallocate(ptr, cap); } @@ -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]); + } }