Enum ndarray::SliceOrIndex [−][src]
A slice (range with step) or an index.
See also the s![]
macro for a convenient way to create a
&SliceInfo<[SliceOrIndex; n], D>
.
Examples
SliceOrIndex::Index(a)
is the index a
. It can also be created with
SliceOrIndex::from(a)
. The Python equivalent is [a]
. The macro
equivalent is s![a]
.
SliceOrIndex::Slice { start: 0, end: None, step: 1 }
is the full range of
an axis. It can also be created with SliceOrIndex::from(..)
. The Python
equivalent is [:]
. The macro equivalent is s![..]
.
SliceOrIndex::Slice { start: a, end: Some(b), step: 2 }
is every second
element from a
until b
. It can also be created with
SliceOrIndex::from(a..b).step_by(2)
. The Python equivalent is [a:b:2]
.
The macro equivalent is s![a..b;2]
.
SliceOrIndex::Slice { start: a, end: None, step: -1 }
is every element,
from a
until the end, in reverse order. It can also be created with
SliceOrIndex::from(a..).step_by(-1)
. The Python equivalent is [a::-1]
.
The macro equivalent is s![a..;-1]
.
Variants
A range with step size. end
is an exclusive index. Negative begin
or end
indexes are counted from the back of the axis. If end
is
None
, the slice extends to the end of the axis.
Index(isize)
A single index.
Implementations
impl SliceOrIndex
[src]
pub fn is_slice(&self) -> bool
[src]
Returns true
if self
is a Slice
value.
pub fn is_index(&self) -> bool
[src]
Returns true
if self
is an Index
value.
pub fn step_by(self, step: isize) -> Self
[src]
Returns a new SliceOrIndex
with the given step size (multiplied with
the previous step size).
step
must be nonzero.
(This method checks with a debug assertion that step
is not zero.)
Trait Implementations
impl Clone for SliceOrIndex
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for SliceOrIndex
[src]
impl Debug for SliceOrIndex
[src]
impl Display for SliceOrIndex
[src]
impl Eq for SliceOrIndex
[src]
impl From<Range<i32>> for SliceOrIndex
[src]
fn from(r: Range<i32>) -> SliceOrIndex
[src]
impl From<Range<isize>> for SliceOrIndex
[src]
fn from(r: Range<isize>) -> SliceOrIndex
[src]
impl From<Range<usize>> for SliceOrIndex
[src]
fn from(r: Range<usize>) -> SliceOrIndex
[src]
impl From<RangeFrom<i32>> for SliceOrIndex
[src]
fn from(r: RangeFrom<i32>) -> SliceOrIndex
[src]
impl From<RangeFrom<isize>> for SliceOrIndex
[src]
fn from(r: RangeFrom<isize>) -> SliceOrIndex
[src]
impl From<RangeFrom<usize>> for SliceOrIndex
[src]
fn from(r: RangeFrom<usize>) -> SliceOrIndex
[src]
impl From<RangeFull> for SliceOrIndex
[src]
fn from(_: RangeFull) -> SliceOrIndex
[src]
impl From<RangeInclusive<i32>> for SliceOrIndex
[src]
fn from(r: RangeInclusive<i32>) -> SliceOrIndex
[src]
impl From<RangeInclusive<isize>> for SliceOrIndex
[src]
fn from(r: RangeInclusive<isize>) -> SliceOrIndex
[src]
impl From<RangeInclusive<usize>> for SliceOrIndex
[src]
fn from(r: RangeInclusive<usize>) -> SliceOrIndex
[src]
impl From<RangeTo<i32>> for SliceOrIndex
[src]
fn from(r: RangeTo<i32>) -> SliceOrIndex
[src]
impl From<RangeTo<isize>> for SliceOrIndex
[src]
fn from(r: RangeTo<isize>) -> SliceOrIndex
[src]
impl From<RangeTo<usize>> for SliceOrIndex
[src]
fn from(r: RangeTo<usize>) -> SliceOrIndex
[src]
impl From<RangeToInclusive<i32>> for SliceOrIndex
[src]
fn from(r: RangeToInclusive<i32>) -> SliceOrIndex
[src]
impl From<RangeToInclusive<isize>> for SliceOrIndex
[src]
fn from(r: RangeToInclusive<isize>) -> SliceOrIndex
[src]
impl From<RangeToInclusive<usize>> for SliceOrIndex
[src]
fn from(r: RangeToInclusive<usize>) -> SliceOrIndex
[src]
impl From<Slice> for SliceOrIndex
[src]
fn from(s: Slice) -> SliceOrIndex
[src]
impl From<i32> for SliceOrIndex
[src]
fn from(r: i32) -> SliceOrIndex
[src]
impl From<isize> for SliceOrIndex
[src]
fn from(r: isize) -> SliceOrIndex
[src]
impl From<usize> for SliceOrIndex
[src]
fn from(r: usize) -> SliceOrIndex
[src]
impl Hash for SliceOrIndex
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<SliceOrIndex> for SliceOrIndex
[src]
fn eq(&self, other: &SliceOrIndex) -> bool
[src]
fn ne(&self, other: &SliceOrIndex) -> bool
[src]
impl StructuralEq for SliceOrIndex
[src]
impl StructuralPartialEq for SliceOrIndex
[src]
Auto Trait Implementations
impl RefUnwindSafe for SliceOrIndex
impl Send for SliceOrIndex
impl Sync for SliceOrIndex
impl Unpin for SliceOrIndex
impl UnwindSafe for SliceOrIndex
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,