Replace transmute with cast
This commit is contained in:
parent
5d59a51bbe
commit
6fc045ae17
|
@ -95,20 +95,20 @@ impl<T, const M: usize, const N: usize> Matrix<T, M, N> {
|
||||||
impl<T, const N: usize> ColVector<T, N> {
|
impl<T, const N: usize> ColVector<T, N> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn map_to_col(slice: &[T; N]) -> &ColVector<T, N> {
|
pub fn map_to_col(slice: &[T; N]) -> &ColVector<T, N> {
|
||||||
unsafe { std::mem::transmute::<&[T; N], &Self>(slice) }
|
unsafe { &*(slice.as_ptr().cast()) }
|
||||||
}
|
}
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn map_to_col_mut(slice: &mut [T; N]) -> &mut ColVector<T, N> {
|
pub fn map_to_col_mut(slice: &mut [T; N]) -> &mut ColVector<T, N> {
|
||||||
unsafe { std::mem::transmute::<&mut [T; N], &mut Self>(slice) }
|
unsafe { &mut *(slice.as_mut_ptr().cast()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, const N: usize> RowVector<T, N> {
|
impl<T, const N: usize> RowVector<T, N> {
|
||||||
pub fn map_to_row(slice: &[T; N]) -> &Self {
|
pub fn map_to_row(slice: &[T; N]) -> &Self {
|
||||||
unsafe { std::mem::transmute::<&[T; N], &Self>(slice) }
|
unsafe { &*(slice.as_ptr().cast()) }
|
||||||
}
|
}
|
||||||
pub fn map_to_row_mut(slice: &mut [T; N]) -> &mut Self {
|
pub fn map_to_row_mut(slice: &mut [T; N]) -> &mut Self {
|
||||||
unsafe { std::mem::transmute::<&mut [T; N], &mut Self>(slice) }
|
unsafe { &mut *(slice.as_mut_ptr().cast()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue