Skip to content

Commit

Permalink
Merge pull request #1353 from biskwikman/iter-debug
Browse files Browse the repository at this point in the history
derived Debug for Iter and IterMut
  • Loading branch information
bluss committed Mar 10, 2024
2 parents f0f4849 + 2205612 commit 3ed2022
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/iterators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,28 @@ 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;

use super::{ArrayBase, ArrayView, ArrayViewMut, Axis, Data, NdProducer, RemoveAxis};
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<A, D> {
ptr: *mut A,
dim: D,
Expand Down Expand Up @@ -306,7 +307,7 @@ where
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum ElementsRepr<S, C> {
Slice(S),
Counted(C),
Expand All @@ -317,11 +318,13 @@ pub enum ElementsRepr<S, C> {
/// Iterator element type is `&'a A`.
///
/// See [`.iter()`](ArrayBase::iter) for more information.
#[derive(Debug)]
pub struct Iter<'a, A, D> {
inner: ElementsRepr<SliceIter<'a, A>, ElementsBase<'a, A, D>>,
}

/// Counted read only iterator
#[derive(Debug)]
pub struct ElementsBase<'a, A, D> {
inner: Baseiter<A, D>,
life: PhantomData<&'a A>,
Expand All @@ -332,13 +335,15 @@ 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<SliceIterMut<'a, A>, ElementsBaseMut<'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<A, D>,
life: PhantomData<&'a mut A>,
Expand Down

0 comments on commit 3ed2022

Please sign in to comment.