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

View File

@ -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<N, $D> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { mem::transmute(self) }
&mut *self.coords
}
}
}