File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -35,18 +35,31 @@ pub struct Slice {
35
35
}
36
36
37
37
impl Slice {
38
+ /// Create a new `Slice` with the given extents.
39
+ ///
40
+ /// See also the `From` impls, converting from ranges; for example
41
+ /// `Slice::from(i..)` or `Slice::from(j..k)`.
42
+ ///
43
+ /// `step` must be nonzero.
44
+ /// (This method checks with a debug assertion that `step` is not zero.)
38
45
pub fn new ( start : isize , end : Option < isize > , step : isize ) -> Slice {
46
+ debug_assert_ne ! ( step, 0 , "Slice::new: step must be nonzero" ) ;
39
47
Slice {
40
48
start,
41
49
end,
42
50
step,
43
51
}
44
52
}
45
53
46
- /// Returns a new `Slice` with the given step size.
54
+ /// Create a new `Slice` with the given step size (multiplied with the
55
+ /// previous step size).
56
+ ///
57
+ /// `step` must be nonzero.
58
+ /// (This method checks with a debug assertion that `step` is not zero.)
47
59
#[ inline]
48
60
pub fn step_by ( self , step : isize ) -> Self {
49
- Slice { step, ..self }
61
+ debug_assert_ne ! ( step, 0 , "Slice::step_by: step must be nonzero" ) ;
62
+ Slice { step : self . step * step, ..self }
50
63
}
51
64
}
52
65
You can’t perform that action at this time.
0 commit comments