From cf283a0ee62b8a08db1b7303cb33f0bd253a461d Mon Sep 17 00:00:00 2001 From: bluss Date: Tue, 23 Mar 2021 21:55:54 +0100 Subject: [PATCH] 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). --- src/arrayvec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arrayvec.rs b/src/arrayvec.rs index 1387e45..24bfb40 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -590,8 +590,8 @@ impl ArrayVec { 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) } }