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