Skip to content

Add support for slicing with subviews #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
03a34a9
Add slicing with subviews
jturner314 Oct 19, 2017
5f1a18a
Remove redundant assert
jturner314 Oct 19, 2017
4d5e3c0
Fix slicing for Rust < 1.21.0
jturner314 Oct 19, 2017
0cd3563
Add type-checking of input size for islice()
jturner314 Oct 19, 2017
e71f636
Pass Si by value instead of by reference
jturner314 Oct 19, 2017
a84c384
Remove support for Rust < 1.21.0
jturner314 Oct 20, 2017
4d2d577
Implement From<Vec<SliceOrIndex>> for SliceInfo
jturner314 Oct 20, 2017
4ee8729
Remove Sized constraint on T in SliceInfo<T, D>
jturner314 Oct 20, 2017
98cdc24
Remove out_ndim member from SliceInfo
jturner314 Oct 20, 2017
b35a7b5
Remove T type parameter from slice*()
jturner314 Oct 20, 2017
27fe458
Make slice() work cleanly for SliceInfo<Vec<_>, _>
jturner314 Oct 20, 2017
23affed
Change transmute() to a pointer cast and deref
jturner314 Oct 21, 2017
66f464d
Add tests for SliceInfo types
jturner314 Oct 21, 2017
89ea1db
Support slicing with more SliceInfo types
jturner314 Oct 21, 2017
6775e41
Remove I: Borrow<_> from *slice*() methods
bluss Oct 24, 2017
9f13954
Remove visibility to SliceInfo.indices
jturner314 Oct 24, 2017
c927ac5
Change Borrow to AsRef
jturner314 Oct 24, 2017
c4f0bf3
Switch from deref + coerce to as_ref
jturner314 Oct 25, 2017
5cdd44c
Remove Si type and rename si module
jturner314 Oct 25, 2017
907d587
Reformat slice module
jturner314 Oct 25, 2017
a056f02
Change SliceInfo to repr(C)
jturner314 Oct 25, 2017
2053e17
Rename .i*() to .*_inplace()
jturner314 Oct 26, 2017
39371d3
Rename .slice_into() to .slice_move()
jturner314 Oct 26, 2017
1848f6b
Fix remaining calls to .islice()
jturner314 Oct 26, 2017
5bc5cd3
Rename .into_subview() to .subview_move()
jturner314 Oct 26, 2017
8c1fc99
Revert "Rename .into_subview() to .subview_move()"
jturner314 Oct 26, 2017
6561c22
Update documentation
jturner314 Oct 26, 2017
db9adfa
Update stride -> step size in docs
jturner314 Oct 26, 2017
6f44bac
Change isize -> Ixs in slice_axis*() signatures
jturner314 Oct 26, 2017
190ca34
Fix failing doc test
jturner314 Oct 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement From<Vec<SliceOrIndex>> for SliceInfo
This also adds `.is_slice()` and `is_index()` methods to `SliceOrIndex`.
  • Loading branch information
jturner314 committed Oct 20, 2017
commit 4d2d577d27abd23652db448fbc327cdf055a325d
24 changes: 24 additions & 0 deletions src/si.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ pub enum SliceOrIndex {
copy_and_clone!{SliceOrIndex}

impl SliceOrIndex {
pub fn is_slice(&self) -> bool {
match self {
&SliceOrIndex::Slice(_) => true,
_ => false,
}
}

pub fn is_index(&self) -> bool {
match self {
&SliceOrIndex::Index(_) => true,
_ => false,
}
}

#[inline]
pub fn step(self, step: Ixs) -> Self {
match self {
Expand Down Expand Up @@ -234,6 +248,16 @@ impl<'a> From<&'a [Si]> for SliceInfo<Vec<SliceOrIndex>, IxDyn> {
}
}

impl From<Vec<SliceOrIndex>> for SliceInfo<Vec<SliceOrIndex>, IxDyn> {
fn from(indices: Vec<SliceOrIndex>) -> Self {
SliceInfo {
out_dim: PhantomData,
out_ndim: indices.iter().filter(|s| s.is_slice()).count(),
indices: indices,
}
}
}

#[doc(hidden)]
pub trait SliceNextDim<D1, D2> {
fn next_dim(&self, (PhantomData<D1>, usize)) -> (PhantomData<D2>, usize);
Expand Down