forked from M-Labs/nalgebra
Merge pull request #1027 from dimforge/slice-into-array
Re-add the conversion from a vector/matrix slice to a static array
This commit is contained in:
commit
803ce0a69f
@ -23,7 +23,7 @@ use crate::base::{
|
|||||||
use crate::base::{DVector, RowDVector, VecStorage};
|
use crate::base::{DVector, RowDVector, VecStorage};
|
||||||
use crate::base::{SliceStorage, SliceStorageMut};
|
use crate::base::{SliceStorage, SliceStorageMut};
|
||||||
use crate::constraint::DimEq;
|
use crate::constraint::DimEq;
|
||||||
use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector};
|
use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector, VectorSlice, VectorSliceMut};
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
|
|
||||||
// TODO: too bad this won't work for slice conversions.
|
// TODO: too bad this won't work for slice conversions.
|
||||||
@ -125,6 +125,24 @@ impl<T: Scalar, const D: usize> From<SVector<T, D>> for [T; D] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const D: usize>
|
||||||
|
From<VectorSlice<'a, T, Const<D>, RStride, CStride>> for [T; D]
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(vec: VectorSlice<'a, T, Const<D>, RStride, CStride>) -> Self {
|
||||||
|
vec.into_owned().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const D: usize>
|
||||||
|
From<VectorSliceMut<'a, T, Const<D>, RStride, CStride>> for [T; D]
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(vec: VectorSliceMut<'a, T, Const<D>, RStride, CStride>) -> Self {
|
||||||
|
vec.into_owned().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Scalar, const D: usize> From<[T; D]> for RowSVector<T, D>
|
impl<T: Scalar, const D: usize> From<[T; D]> for RowSVector<T, D>
|
||||||
where
|
where
|
||||||
Const<D>: IsNotStaticOne,
|
Const<D>: IsNotStaticOne,
|
||||||
@ -197,8 +215,26 @@ impl<T: Scalar, const R: usize, const C: usize> From<[[T; R]; C]> for SMatrix<T,
|
|||||||
|
|
||||||
impl<T: Scalar, const R: usize, const C: usize> From<SMatrix<T, R, C>> for [[T; R]; C] {
|
impl<T: Scalar, const R: usize, const C: usize> From<SMatrix<T, R, C>> for [[T; R]; C] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(vec: SMatrix<T, R, C>) -> Self {
|
fn from(mat: SMatrix<T, R, C>) -> Self {
|
||||||
vec.data.0
|
mat.data.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const R: usize, const C: usize>
|
||||||
|
From<MatrixSlice<'a, T, Const<R>, Const<C>, RStride, CStride>> for [[T; R]; C]
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(mat: MatrixSlice<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||||
|
mat.into_owned().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const R: usize, const C: usize>
|
||||||
|
From<MatrixSliceMut<'a, T, Const<R>, Const<C>, RStride, CStride>> for [[T; R]; C]
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(mat: MatrixSliceMut<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||||
|
mat.into_owned().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user