We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
grow
1 parent f96322b commit b28c6b3Copy full SHA for b28c6b3
lib.rs
@@ -665,6 +665,8 @@ impl<A: Array> SmallVec<A> {
665
if unspilled {
666
return;
667
}
668
+ } else {
669
+ return;
670
671
deallocate(ptr, cap);
672
@@ -2329,4 +2331,18 @@ mod tests {
2329
2331
v.push(4);
2330
2332
assert_eq!(v[..], [4]);
2333
2334
+
2335
+ #[test]
2336
+ fn grow_spilled_same_size() {
2337
+ let mut v: SmallVec<[u8; 2]> = SmallVec::new();
2338
+ v.push(0);
2339
+ v.push(1);
2340
+ v.push(2);
2341
+ assert!(v.spilled());
2342
+ assert_eq!(v.capacity(), 4);
2343
+ // grow with the same capacity
2344
+ v.grow(4);
2345
2346
+ assert_eq!(v[..], [0, 1, 2]);
2347
+ }
2348
0 commit comments