Distinguish erased ownership bindings
This commit is contained in:
+2
-2
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user