From 39f0bfabd5f211d3efa437b2eb72565441a46e2c Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 Jan 2024 14:25:20 +0900 Subject: [PATCH 1/2] derived Debug for Iter and IterMut --- src/iterators/mod.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/iterators/mod.rs b/src/iterators/mod.rs index 6bac471bd..821e8d153 100644 --- a/src/iterators/mod.rs +++ b/src/iterators/mod.rs @@ -14,11 +14,11 @@ pub mod iter; mod lanes; mod windows; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; use std::iter::FromIterator; use std::marker::PhantomData; use std::ptr; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; use crate::Ix1; @@ -26,15 +26,16 @@ use super::{ArrayBase, ArrayView, ArrayViewMut, Axis, Data, NdProducer, RemoveAx use super::{Dimension, Ix, Ixs}; pub use self::chunks::{ExactChunks, ExactChunksIter, ExactChunksIterMut, ExactChunksMut}; +pub use self::into_iter::IntoIter; pub use self::lanes::{Lanes, LanesMut}; pub use self::windows::Windows; -pub use self::into_iter::IntoIter; use std::slice::{self, Iter as SliceIter, IterMut as SliceIterMut}; /// Base for iterators over all axes. /// /// Iterator element type is `*mut A`. +#[derive(Debug)] pub struct Baseiter { ptr: *mut A, dim: D, @@ -306,7 +307,7 @@ where } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum ElementsRepr { Slice(S), Counted(C), @@ -317,11 +318,19 @@ pub enum ElementsRepr { /// Iterator element type is `&'a A`. /// /// See [`.iter()`](ArrayBase::iter) for more information. +#[derive(Debug)] pub struct Iter<'a, A, D> { inner: ElementsRepr, ElementsBase<'a, A, D>>, } +// impl<'a, A, D> fmt::Debug for Iter<'a, A, D> { +// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +// f.debug_struct("Iter").field("inner", &self.inner).finish() +// } +// } + /// Counted read only iterator +#[derive(Debug)] pub struct ElementsBase<'a, A, D> { inner: Baseiter, life: PhantomData<&'a A>, @@ -332,6 +341,7 @@ pub struct ElementsBase<'a, A, D> { /// Iterator element type is `&'a mut A`. /// /// See [`.iter_mut()`](ArrayBase::iter_mut) for more information. +#[derive(Debug)] pub struct IterMut<'a, A, D> { inner: ElementsRepr, ElementsBaseMut<'a, A, D>>, } @@ -339,6 +349,7 @@ pub struct IterMut<'a, A, D> { /// An iterator over the elements of an array. /// /// Iterator element type is `&'a mut A`. +#[derive(Debug)] pub struct ElementsBaseMut<'a, A, D> { inner: Baseiter, life: PhantomData<&'a mut A>, From 2205612c96a30bdb3b60736f3d04f6ee7db09f6a Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 30 Jan 2024 16:00:30 +0900 Subject: [PATCH 2/2] removed commented code --- src/iterators/mod.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/iterators/mod.rs b/src/iterators/mod.rs index 821e8d153..49c9c1887 100644 --- a/src/iterators/mod.rs +++ b/src/iterators/mod.rs @@ -323,12 +323,6 @@ pub struct Iter<'a, A, D> { inner: ElementsRepr, ElementsBase<'a, A, D>>, } -// impl<'a, A, D> fmt::Debug for Iter<'a, A, D> { -// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -// f.debug_struct("Iter").field("inner", &self.inner).finish() -// } -// } - /// Counted read only iterator #[derive(Debug)] pub struct ElementsBase<'a, A, D> {