Skip to content

Commit 5ff331a

Browse files
committed
use ManuallyDrop instead of mem-forget-in-disguise
1 parent 27a0f9c commit 5ff331a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/bytes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use core::iter::FromIterator;
22
use core::ops::{Deref, RangeBounds};
33
use core::{cmp, fmt, hash, mem, ptr, slice, usize};
4+
use core::mem::ManuallyDrop;
45

56
use alloc::{borrow::Borrow, boxed::Box, string::String, vec::Vec};
67

@@ -804,10 +805,9 @@ impl From<Vec<u8>> for Bytes {
804805
return Bytes::new();
805806
}
806807

807-
let slice = vec.into_boxed_slice();
808+
let slice = ManuallyDrop::new(vec.into_boxed_slice());
808809
let len = slice.len();
809810
let ptr = slice.as_ptr();
810-
drop(Box::into_raw(slice));
811811

812812
if ptr as usize & 0x1 == 0 {
813813
let data = ptr as usize | KIND_VEC;

0 commit comments

Comments
 (0)