From c6d5d8a1a67d9eff236088e7a5284e0970fdf6ed Mon Sep 17 00:00:00 2001 From: Michael Morgan Date: Fri, 9 Oct 2020 14:14:14 -0400 Subject: [PATCH] Remove unsafe statement in Point::deref by forwarding to Vector. Since both impls are #[inline], this should have no performance impact. --- src/geometry/point_coordinates.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/geometry/point_coordinates.rs b/src/geometry/point_coordinates.rs index b56e120e..268c9b0d 100644 --- a/src/geometry/point_coordinates.rs +++ b/src/geometry/point_coordinates.rs @@ -1,4 +1,3 @@ -use std::mem; use std::ops::{Deref, DerefMut}; use crate::base::allocator::Allocator; @@ -22,7 +21,7 @@ macro_rules! deref_impl( #[inline] fn deref(&self) -> &Self::Target { - unsafe { mem::transmute(self) } + &*self.coords } } @@ -30,7 +29,7 @@ macro_rules! deref_impl( where DefaultAllocator: Allocator { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { - unsafe { mem::transmute(self) } + &mut *self.coords } } }