Skip to content

Commit 5df012c

Browse files
committed
API: Change SliceOrIndex::step_by step to be multiplicative (cumulative)
1 parent 0ece678 commit 5df012c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/slice.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,20 @@ impl SliceOrIndex {
172172
}
173173
}
174174

175-
/// Returns a new `SliceOrIndex` with the given step size.
175+
/// Returns a new `SliceOrIndex` with the given step size (multiplied with
176+
/// the previous step size).
176177
#[inline]
177178
pub fn step_by(self, step: isize) -> Self {
178179
match self {
179-
SliceOrIndex::Slice { start, end, .. } => SliceOrIndex::Slice { start, end, step },
180+
SliceOrIndex::Slice {
181+
start,
182+
end,
183+
step: orig_step,
184+
} => SliceOrIndex::Slice {
185+
start,
186+
end,
187+
step: orig_step * step,
188+
},
180189
SliceOrIndex::Index(s) => SliceOrIndex::Index(s),
181190
}
182191
}

0 commit comments

Comments
 (0)