FIX: Code cleanup in .into_inner()

Prefer ManuallyDrop instead of forget (more modern style preference -
with the benefit that the ManuallyDrop style sets up the non-dropping
before taking further actions).
This commit is contained in:
bluss
2021-03-23 21:55:54 +01:00
parent 74039f1b4c
commit cf283a0ee6
+2 -2
View File
@@ -590,8 +590,8 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
Err(self)
} else {
unsafe {
let array = ptr::read(self.as_ptr() as *const [T; CAP]);
mem::forget(self);
let self_ = ManuallyDrop::new(self);
let array = ptr::read(self_.as_ptr() as *const [T; CAP]);
Ok(array)
}
}