From a95d3241b33b2fb34cbf1fa6ee63b12ba852ea40 Mon Sep 17 00:00:00 2001 From: Matthijs Brobbel Date: Fri, 14 May 2021 16:51:12 +0200 Subject: [PATCH] Vec makes no guarantees about its memory layout --- src/buffer.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 62dc717a..69bdd891 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -273,15 +273,8 @@ impl From> for Buffer where T: Primitive, { - fn from(mut vec: Vec) -> Self { - // todo(mb): is this a safe assumption? - match Layout::array::(vec.capacity()) { - Ok(vec_layout) if vec_layout == layout::(vec.capacity()) => Self { - ptr: unsafe { NonNull::new_unchecked(vec.as_mut_ptr()) }, - len: vec.len(), - }, - _ => Self::from_slice(&vec), - } + fn from(vec: Vec) -> Self { + Self::from_slice(&vec) } }