diff --git a/src/core/conversion.rs b/src/core/conversion.rs index 2ed03ece..fb0a48be 100644 --- a/src/core/conversion.rs +++ b/src/core/conversion.rs @@ -7,7 +7,8 @@ use alga::general::{SubsetOf, SupersetOf}; use core::{Scalar, Matrix}; use core::dimension::{Dim, DimName, DimNameMul, DimNameProd, U1, U2, U3, U4, U5, U6}; use core::constraint::{ShapeConstraint, SameNumberOfRows, SameNumberOfColumns}; -use core::storage::OwnedStorage; +use core::storage::{Storage, StorageMut, OwnedStorage}; +use core::iter::{MatrixIter, MatrixIterMut}; use core::allocator::{OwnedAllocator, SameShapeAllocator}; @@ -62,6 +63,26 @@ impl SubsetOf> for Matrix } } +impl<'a, N: Scalar, R: Dim, C: Dim, S: Storage> IntoIterator for &'a Matrix { + type Item = &'a N; + type IntoIter = MatrixIter<'a, N, R, C, S>; + + #[inline] + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +impl<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> IntoIterator for &'a mut Matrix { + type Item = &'a mut N; + type IntoIter = MatrixIterMut<'a, N, R, C, S>; + + #[inline] + fn into_iter(self) -> Self::IntoIter { + self.iter_mut() + } +} + macro_rules! impl_from_into_asref_1D( ($($Dim: ident => $SZ: expr);* $(;)*) => {$(