From 5fb4b04cb015d8ae973ce740b128cea85bc63ee7 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 8 Jun 2020 10:26:12 +0800 Subject: [PATCH] Put type on transmute call. --- src/utils.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index ccd3d6be..4a8cd3c8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -190,8 +190,9 @@ impl Clone for StaticVec { if self.is_fixed_storage() { for x in 0..self.len { - let item: &T = unsafe { mem::transmute(self.list.get(x).unwrap()) }; - value.list[x] = MaybeUninit::new(item.clone()); + let item = self.list.get(x).unwrap(); + let item_value = unsafe { mem::transmute::<_, &T>(item) }; + value.list[x] = MaybeUninit::new(item_value.clone()); } } else { value.more = self.more.clone(); @@ -424,7 +425,7 @@ impl StaticVec { panic!("index OOB in StaticVec"); } - let list: &[T; MAX_STATIC_VEC] = unsafe { mem::transmute(&self.list) }; + let list = unsafe { mem::transmute::<_, &[T; MAX_STATIC_VEC]>(&self.list) }; if self.is_fixed_storage() { list.get(index).unwrap() @@ -442,7 +443,7 @@ impl StaticVec { panic!("index OOB in StaticVec"); } - let list: &mut [T; MAX_STATIC_VEC] = unsafe { mem::transmute(&mut self.list) }; + let list = unsafe { mem::transmute::<_, &mut [T; MAX_STATIC_VEC]>(&mut self.list) }; if self.is_fixed_storage() { list.get_mut(index).unwrap() @@ -452,7 +453,7 @@ impl StaticVec { } /// Get an iterator to entries in the `StaticVec`. pub fn iter(&self) -> impl Iterator { - let list: &[T; MAX_STATIC_VEC] = unsafe { mem::transmute(&self.list) }; + let list = unsafe { mem::transmute::<_, &[T; MAX_STATIC_VEC]>(&self.list) }; if self.is_fixed_storage() { list[..self.len].iter() @@ -462,7 +463,7 @@ impl StaticVec { } /// Get a mutable iterator to entries in the `StaticVec`. pub fn iter_mut(&mut self) -> impl Iterator { - let list: &mut [T; MAX_STATIC_VEC] = unsafe { mem::transmute(&mut self.list) }; + let list = unsafe { mem::transmute::<_, &mut [T; MAX_STATIC_VEC]>(&mut self.list) }; if self.is_fixed_storage() { list[..self.len].iter_mut() @@ -549,7 +550,7 @@ impl fmt::Debug for StaticVec { impl AsRef<[T]> for StaticVec { fn as_ref(&self) -> &[T] { - let list: &[T; MAX_STATIC_VEC] = unsafe { mem::transmute(&self.list) }; + let list = unsafe { mem::transmute::<_, &[T; MAX_STATIC_VEC]>(&self.list) }; if self.is_fixed_storage() { &list[..self.len] @@ -561,7 +562,7 @@ impl AsRef<[T]> for StaticVec { impl AsMut<[T]> for StaticVec { fn as_mut(&mut self) -> &mut [T] { - let list: &mut [T; MAX_STATIC_VEC] = unsafe { mem::transmute(&mut self.list) }; + let list = unsafe { mem::transmute::<_, &mut [T; MAX_STATIC_VEC]>(&mut self.list) }; if self.is_fixed_storage() { &mut list[..self.len]