Hello dear maintainers, and thank you for your work on this crate !
I'm currently writing some voxel-processing functions and I'm facing a strange fact: the Zip iterator-like struct of ndarray doesn't seems to implement the IntoIterator trait. It does implement however the IntoParallelIterator trait, but it is of no help in my case where I want to filter and sum over the iterator elements.
The probleme of not implementing the Iterator trait is a general concern I think, but I'm specifically trying to do something like this:
// idiomatic rust
let acc = Zip::indexed(voxel)
.filter_map(|position, density| {...})
.sum()
// imperative style
let mut acc = 0.;
for (position, density) in Zip::indexed(voxel) {
if ... { acc += ... }
}
None of the above ways are working because of the IntoIterator trait missing. I also tried ArrayBase::indexed_iter() but it gives tuple indices instead of fixed-arrays (not convenient for further compuations); plus it iterates in the logical order so not the most efficient depending on the input strides.
Could possibily you implement IntoIterator for Zip as it already have IntoParallelIterator ?
Edit:
in fact, both Zip::indexed and ArrayBase::indexed_iter yield a tuple for index. not sure why because the docs says I should get a [usize; 3] instead. I would be much more convenient to have such an array in my opinion ... but this is an other question.
Hello dear maintainers, and thank you for your work on this crate !
I'm currently writing some voxel-processing functions and I'm facing a strange fact: the
Zipiterator-like struct ofndarraydoesn't seems to implement theIntoIteratortrait. It does implement however theIntoParallelIteratortrait, but it is of no help in my case where I want to filter and sum over the iterator elements.The probleme of not implementing the
Iteratortrait is a general concern I think, but I'm specifically trying to do something like this:None of the above ways are working because of the
IntoIteratortrait missing. I also triedArrayBase::indexed_iter()but it gives tuple indices instead of fixed-arrays (not convenient for further compuations); plus it iterates in the logical order so not the most efficient depending on the input strides.Could possibily you implement
IntoIteratorforZipas it already haveIntoParallelIterator?Edit:
in fact, both
Zip::indexedandArrayBase::indexed_iteryield a tuple for index. not sure why because the docs says I should get a[usize; 3]instead. I would be much more convenient to have such an array in my opinion ... but this is an other question.