[][src]Enum ndarray::SliceOrIndex

pub enum SliceOrIndex {
    Slice {
        start: isize,
        end: Option<isize>,
        step: isize,
    },
    Index(isize),
}

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. 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.

Fields of Slice

A single index.

Methods

impl SliceOrIndex
[src]

Returns true if self is a Slice value.

Returns true if self is an Index value.

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 Debug for SliceOrIndex
[src]

Formats the value using the given formatter. Read more

impl PartialEq for SliceOrIndex
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for SliceOrIndex
[src]

impl Hash for SliceOrIndex
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl Copy for SliceOrIndex
[src]

impl Clone for SliceOrIndex
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Display for SliceOrIndex
[src]

Formats the value using the given formatter. Read more

impl From<Slice> for SliceOrIndex
[src]

Performs the conversion.

impl From<isize> for SliceOrIndex
[src]

Performs the conversion.

impl From<Range<isize>> for SliceOrIndex
[src]

Performs the conversion.

impl From<RangeFrom<isize>> for SliceOrIndex
[src]

Performs the conversion.

impl From<RangeTo<isize>> for SliceOrIndex
[src]

Performs the conversion.

impl From<usize> for SliceOrIndex
[src]

Performs the conversion.

impl From<Range<usize>> for SliceOrIndex
[src]

Performs the conversion.

impl From<RangeFrom<usize>> for SliceOrIndex
[src]

Performs the conversion.

impl From<RangeTo<usize>> for SliceOrIndex
[src]

Performs the conversion.

impl From<i32> for SliceOrIndex
[src]

Performs the conversion.

impl From<Range<i32>> for SliceOrIndex
[src]

Performs the conversion.

impl From<RangeFrom<i32>> for SliceOrIndex
[src]

Performs the conversion.

impl From<RangeTo<i32>> for SliceOrIndex
[src]

Performs the conversion.

impl From<RangeFull> for SliceOrIndex
[src]

Performs the conversion.

Auto Trait Implementations

impl Send for SliceOrIndex

impl Sync for SliceOrIndex

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> From for T
[src]

Performs the conversion.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

Converts the given value to a String. Read more

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more