From 0754bd28f332c271c5f62633d5a4c46a32beaf5c Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Tue, 27 Jun 2023 14:02:20 +0300 Subject: [PATCH 1/2] Add `Clone` to `MatrixIter` and `MatrixIterMut` --- src/base/iter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/iter.rs b/src/base/iter.rs index b396b271..a076bd99 100644 --- a/src/base/iter.rs +++ b/src/base/iter.rs @@ -17,7 +17,7 @@ use crate::base::{Matrix, MatrixView, MatrixViewMut, Scalar}; macro_rules! iterator { (struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => { /// An iterator through a dense matrix with arbitrary strides matrix. - #[derive(Debug)] + #[derive(Clone, Debug)] pub struct $Name<'a, T, R: Dim, C: Dim, S: 'a + $Storage> { ptr: $Ptr, inner_ptr: $Ptr, From 922b0dbfa3b623e8362a599985eda7cc8ab851e0 Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Sat, 8 Jul 2023 17:47:53 +0300 Subject: [PATCH 2/2] Derive Clone only on non-mutable version --- src/base/iter.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/base/iter.rs b/src/base/iter.rs index a076bd99..ebffdb07 100644 --- a/src/base/iter.rs +++ b/src/base/iter.rs @@ -15,9 +15,9 @@ use crate::base::storage::{RawStorage, RawStorageMut}; use crate::base::{Matrix, MatrixView, MatrixViewMut, Scalar}; macro_rules! iterator { - (struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => { + (struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty, $($derives:ident),* $(,)?) => { /// An iterator through a dense matrix with arbitrary strides matrix. - #[derive(Clone, Debug)] + #[derive($($derives),*)] pub struct $Name<'a, T, R: Dim, C: Dim, S: 'a + $Storage> { ptr: $Ptr, inner_ptr: $Ptr, @@ -177,8 +177,8 @@ macro_rules! iterator { }; } -iterator!(struct MatrixIter for RawStorage.ptr -> *const T, &'a T, &'a S); -iterator!(struct MatrixIterMut for RawStorageMut.ptr_mut -> *mut T, &'a mut T, &'a mut S); +iterator!(struct MatrixIter for RawStorage.ptr -> *const T, &'a T, &'a S, Clone, Debug); +iterator!(struct MatrixIterMut for RawStorageMut.ptr_mut -> *mut T, &'a mut T, &'a mut S, Debug); /* *