Skip to content

Commit

Permalink
FIX: Remove extra generics in Slice::new
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bluss committed Nov 20, 2017
1 parent 5802f00 commit 3d9134b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@ use super::{Dimension, Ixs};
/// The Python equivalent is `[a::-1]`.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Slice {
pub start: Ixs,
pub end: Option<Ixs>,
pub step: Ixs,
pub start: isize,
pub end: Option<isize>,
pub step: isize,
}

impl Slice {
pub fn new<I>(start: Ixs, end: I, step: Ixs) -> Slice
where
I: Into<Option<Ixs>>,
{
pub fn new(start: isize, end: Option<isize>, step: isize) -> Slice {
Slice {
start,
end: end.into(),
end,
step,
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ fn slice_oob()
#[test]
fn slice_axis_oob() {
let a = RcArray::<i32, _>::zeros((3, 4));
let _vi = a.slice_axis(Axis(0), Slice::new(0, 10, 1));
let _vi = a.slice_axis(Axis(0), Slice::new(0, Some(10), 1));
}

#[should_panic]
Expand Down

0 comments on commit 3d9134b

Please sign in to comment.