Skip to content

Commit f2dff3e

Browse files
committed
API: Add debug assertion for step != 0 in SliceOrIndex::step_by
1 parent 5df012c commit f2dff3e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/slice.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,12 @@ impl SliceOrIndex {
174174

175175
/// Returns a new `SliceOrIndex` with the given step size (multiplied with
176176
/// the previous step size).
177+
///
178+
/// `step` must be nonzero.
179+
/// (This method checks with a debug assertion that `step` is not zero.)
177180
#[inline]
178181
pub fn step_by(self, step: isize) -> Self {
182+
debug_assert_ne!(step, 0, "SliceOrIndex::step_by: step must be nonzero");
179183
match self {
180184
SliceOrIndex::Slice {
181185
start,

0 commit comments

Comments
 (0)