From 801d8a61a68d1d2ecaa0c19481ac06e84fef558d Mon Sep 17 00:00:00 2001 From: Cryptjar Date: Fri, 18 Jun 2021 02:43:05 +0200 Subject: [PATCH] Add a `From` impl to convert `DVectorSlice[mut]` back to into a slice. --- src/base/conversion.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/base/conversion.rs b/src/base/conversion.rs index 532ab8ed..94fd4a3a 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -452,6 +452,12 @@ impl<'a, T: Scalar + Copy> From<&'a [T]> for DVectorSlice<'a, T> { } } +impl<'a, T: Scalar> From> for &'a [T] { + fn from(vec: DVectorSlice<'a, T>) -> &'a [T] { + vec.data.into_slice() + } +} + impl<'a, T: Scalar + Copy> From<&'a mut [T]> for DVectorSliceMut<'a, T> { #[inline] fn from(slice: &'a mut [T]) -> Self { @@ -459,6 +465,12 @@ impl<'a, T: Scalar + Copy> From<&'a mut [T]> for DVectorSliceMut<'a, T> { } } +impl<'a, T: Scalar> From> for &'a mut [T] { + fn from(vec: DVectorSliceMut<'a, T>) -> &'a mut [T] { + vec.data.into_slice_mut() + } +} + impl From<[OMatrix; 2]> for OMatrix where