Skip to content

Commit cc53dd2

Browse files
committed
Rewrite next_for using next_for_mut
1 parent 13b2736 commit cc53dd2

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/dimension/dimension_trait.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,9 @@ pub trait Dimension:
196196
/// Iteration -- Use self as size, and return next index after `index`
197197
/// or None if there are no more.
198198
#[inline]
199-
fn next_for(&self, index: Self) -> Option<Self>
199+
fn next_for(&self, mut index: Self) -> Option<Self>
200200
{
201-
let mut index = index;
202-
let mut done = false;
203-
for (&dim, ix) in zip(self.slice(), index.slice_mut()).rev() {
204-
*ix += 1;
205-
if *ix == dim {
206-
*ix = 0;
207-
} else {
208-
done = true;
209-
break;
210-
}
211-
}
212-
if done {
201+
if self.next_for_mut(&mut index) {
213202
Some(index)
214203
} else {
215204
None

0 commit comments

Comments
 (0)