Merge pull request #776 from aniketatgithub/fix-771-uniquearray-append-moving

[BasicContainers] Fix UniqueArray.append(moving:) dropping and leaking every element
This commit is contained in:
Karoy Lorentey authored and GitHub committed 2026-10-21 16:33:17 -07:00
commit 1209f9e410
2 files changed
+27 -1

No files matched your search

@@ -160,8 +160,9 @@ extension UniqueArray where Element: ~Copyable {
_ensureFreeCapacity(items.count)
return items.edit { source in
unsafe source.withUnsafeMutableBufferPointer { buffer, count in
let extracted = unsafe buffer._extracting(first: count)
count = 0
return unsafe _storage.append(moving: buffer._extracting(first: count))
return unsafe _storage.append(moving: extracted)
}
}
}