Distinguish erased ownership bindings

This commit is contained in:
2026-07-31 03:39:11 +02:00
parent 9620281df9
commit 13f713b820
+2 -2
View File
@@ -38,10 +38,10 @@ impl<'vec, T> ContentGuard<'vec, T> {
/// The guard remains usable with an empty, zero-capacity vector.
pub fn take(&mut self) -> Vec<T> {
let old_erased = std::mem::replace(self.erased, (self.reerase)(Vec::new()));
let old_erased = ManuallyDrop::new(old_erased);
let erased_owner = ManuallyDrop::new(old_erased);
// SAFETY: The erased pointer, length, and capacity are valid for a Vec<T>.
// ManuallyDrop prevents the old TypeErasedVec from double-freeing the allocation.
unsafe { old_erased.parts.into_vec() }
unsafe { erased_owner.parts.into_vec() }
}
/// Calls `function` with the underlying vector and then type-erases it again.