Skip to content

Commit 3d9134b

Browse files
committed
FIX: Remove extra generics in Slice::new
Just to be very conservative, scale this use of Option<isize> back. I'm not fond of this solution for overloading, it feels like it doesn't scale. ndarray is complicated enough on the whole, let's keep each part as simple as possible.
1 parent 5802f00 commit 3d9134b

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/slice.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,16 @@ use super::{Dimension, Ixs};
2929
/// The Python equivalent is `[a::-1]`.
3030
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
3131
pub struct Slice {
32-
pub start: Ixs,
33-
pub end: Option<Ixs>,
34-
pub step: Ixs,
32+
pub start: isize,
33+
pub end: Option<isize>,
34+
pub step: isize,
3535
}
3636

3737
impl Slice {
38-
pub fn new<I>(start: Ixs, end: I, step: Ixs) -> Slice
39-
where
40-
I: Into<Option<Ixs>>,
41-
{
38+
pub fn new(start: isize, end: Option<isize>, step: isize) -> Slice {
4239
Slice {
4340
start,
44-
end: end.into(),
41+
end,
4542
step,
4643
}
4744
}

tests/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn slice_oob()
252252
#[test]
253253
fn slice_axis_oob() {
254254
let a = RcArray::<i32, _>::zeros((3, 4));
255-
let _vi = a.slice_axis(Axis(0), Slice::new(0, 10, 1));
255+
let _vi = a.slice_axis(Axis(0), Slice::new(0, Some(10), 1));
256256
}
257257

258258
#[should_panic]

0 commit comments

Comments
 (0)