Fix unsoundness in `into_slice` by adding `ContiguousStorage` bound.

This commit is contained in:
Cryptjar 2021-06-18 13:18:33 +02:00
parent 801d8a61a6
commit 1554c0114e
1 changed files with 4 additions and 0 deletions

View File

@ -80,6 +80,8 @@ macro_rules! slice_storage_impl(
impl <'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> impl <'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
$T<'a, T, R, C, RStride, CStride> $T<'a, T, R, C, RStride, CStride>
where
Self: ContiguousStorage<T, R, C>
{ {
/// Extracts the original slice from this storage /// Extracts the original slice from this storage
pub fn into_slice(self) -> &'a [T] { pub fn into_slice(self) -> &'a [T] {
@ -125,6 +127,8 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
SliceStorageMut<'a, T, R, C, RStride, CStride> SliceStorageMut<'a, T, R, C, RStride, CStride>
where
Self: ContiguousStorageMut<T, R, C>,
{ {
/// Extracts the original slice from this storage /// Extracts the original slice from this storage
pub fn into_slice_mut(self) -> &'a mut [T] { pub fn into_slice_mut(self) -> &'a mut [T] {