Remove unsafe statement in Point::deref by forwarding to Vector.

Since both impls are #[inline], this should have no performance impact.
This commit is contained in:
Michael Morgan 2020-10-09 14:14:14 -04:00
parent c1eaac2fae
commit c6d5d8a1a6

View File

@ -1,4 +1,3 @@
use std::mem;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use crate::base::allocator::Allocator; use crate::base::allocator::Allocator;
@ -22,7 +21,7 @@ macro_rules! deref_impl(
#[inline] #[inline]
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
unsafe { mem::transmute(self) } &*self.coords
} }
} }
@ -30,7 +29,7 @@ macro_rules! deref_impl(
where DefaultAllocator: Allocator<N, $D> { where DefaultAllocator: Allocator<N, $D> {
#[inline] #[inline]
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { mem::transmute(self) } &mut *self.coords
} }
} }
} }