Skip to content

Commit b26ec6c

Browse files
committed
Add split_at methods for AxisChunksIter/Mut
1 parent af9d949 commit b26ec6c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/iterators/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,31 @@ macro_rules! chunk_iter_impl {
13031303
}
13041304
}
13051305
}
1306+
1307+
/// Splits the iterator at index, yielding two disjoint iterators.
1308+
///
1309+
/// `index` is relative to the current state of the iterator (which is not
1310+
/// necessarily the start of the axis).
1311+
///
1312+
/// **Panics** if `index` is strictly greater than the iterator's remaining
1313+
/// length.
1314+
pub fn split_at(self, index: usize) -> (Self, Self) {
1315+
let (left, right) = self.iter.split_at(index);
1316+
(
1317+
Self {
1318+
iter: left,
1319+
partial_chunk_index: self.partial_chunk_index,
1320+
partial_chunk_dim: self.partial_chunk_dim.clone(),
1321+
life: self.life,
1322+
},
1323+
Self {
1324+
iter: right,
1325+
partial_chunk_index: self.partial_chunk_index,
1326+
partial_chunk_dim: self.partial_chunk_dim,
1327+
life: self.life,
1328+
},
1329+
)
1330+
}
13061331
}
13071332

13081333
impl<'a, A, D> Iterator for $iter<'a, A, D>

0 commit comments

Comments
 (0)