File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,15 @@ 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,
@@ -44,8 +52,12 @@ impl Slice {
44
52
}
45
53
46
54
/// Returns a new `Slice` with the given step size.
55
+ ///
56
+ /// `step` must be nonzero.
57
+ /// (This method checks with a debug assertion that `step` is not zero.)
47
58
#[ inline]
48
- pub fn step_by ( self , step : Ixs ) -> Self {
59
+ pub fn step_by ( self , step : isize ) -> Self {
60
+ debug_assert_ne ! ( step, 0 , "Slice::step_by: step must be nonzero" ) ;
49
61
Slice { step, ..self }
50
62
}
51
63
}
You can’t perform that action at this time.
0 commit comments