Merge pull request #770 from msmorgan/safe_point_deref

Remove unsafe statement in Point::deref by forwarding to Vector.
This commit is contained in:
Sébastien Crozet 2020-10-10 10:37:15 +02:00 committed by GitHub
commit f79f1972e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

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
} }
} }
} }