Skip to content

Commit 71b53ab

Browse files
committed
Check expr type for ;step in s![] at compile time
Before, if the `expr;step` notation was used with an index as the `expr`, e.g. `s![4;2]`, the macro would panic at runtime. Now, it errors at compile time. This is accomplished by converting the `expr` to a `Slice` before converting it into the final `AxisSliceInfo`.
1 parent 2bcbb2a commit 71b53ab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/slice.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,9 @@ macro_rules! s(
880880
};
881881
// convert range/index/new-axis and step into AxisSliceInfo
882882
(@convert $r:expr, $s:expr) => {
883-
<$crate::AxisSliceInfo as ::std::convert::From<_>>::from($r).step_by($s as isize)
883+
<$crate::AxisSliceInfo as ::std::convert::From<_>>::from(
884+
<$crate::Slice as ::std::convert::From<_>>::from($r).step_by($s as isize)
885+
)
884886
};
885887
($($t:tt)*) => {
886888
$crate::s![@parse

0 commit comments

Comments
 (0)