From 8718d65f906a9b4a9da4ad709478d7c0b8291674 Mon Sep 17 00:00:00 2001 From: EvilMuffinHa Date: Tue, 2 Aug 2022 20:51:21 -0400 Subject: [PATCH] drop refixed --- src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 60762a2..52f0f64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,10 +44,8 @@ impl Drop for SmallInt { fn drop(&mut self) { if let Self::Heap((r, s)) = self { let size = usize::try_from(s.abs()).unwrap(); - let mut slice = unsafe { core::slice::from_raw_parts(r, size) }; - unsafe { - core::ptr::drop_in_place(&mut slice); - } + let slice = unsafe { core::slice::from_raw_parts_mut(*r, size) }; + unsafe { std::mem::drop(Box::from_raw(slice)) } } } @@ -96,7 +94,7 @@ impl From for SmallInt { while v != 0 { vec.push(v as u32); - v = (v >> 1) >> (32 - 1); + v >>= 32; } let mut slice = ManuallyDrop::new(vec.into_boxed_slice()); SmallInt::Heap((slice.as_mut_ptr(), isize::try_from(slice.len()).unwrap()))