From 21c12f26ec97e9538244cdf3fc351dd4e8ab9615 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 8 Jul 2020 12:51:05 +0800 Subject: [PATCH] Liballoc IntoIter use as_mut_slice directly --- src/liballoc/vec.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 5db96a504a6a6..32142bc83d029 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2637,11 +2637,7 @@ impl IntoIter { /// ``` #[stable(feature = "vec_into_iter_as_slice", since = "1.15.0")] pub fn as_mut_slice(&mut self) -> &mut [T] { - unsafe { &mut *self.as_raw_mut_slice() } - } - - fn as_raw_mut_slice(&mut self) -> *mut [T] { - ptr::slice_from_raw_parts_mut(self.ptr as *mut T, self.len()) + unsafe { &mut *ptr::slice_from_raw_parts_mut(self.ptr as *mut T, self.len()) } } } @@ -2760,7 +2756,7 @@ unsafe impl<#[may_dangle] T> Drop for IntoIter { let guard = DropGuard(self); // destroy the remaining elements unsafe { - ptr::drop_in_place(guard.0.as_raw_mut_slice()); + ptr::drop_in_place(guard.0.as_mut_slice()); } // now `guard` will be dropped and do the rest }