Skip to content

Commit cf283a0

Browse files
committed
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).
1 parent 74039f1 commit cf283a0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/arrayvec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
590590
Err(self)
591591
} else {
592592
unsafe {
593-
let array = ptr::read(self.as_ptr() as *const [T; CAP]);
594-
mem::forget(self);
593+
let self_ = ManuallyDrop::new(self);
594+
let array = ptr::read(self_.as_ptr() as *const [T; CAP]);
595595
Ok(array)
596596
}
597597
}

0 commit comments

Comments
 (0)