Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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