Enum ndarray::SliceInfoElem[][src]

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

A slice (range with step), an index, or a new axis token.

See also the s![] macro for a convenient way to create a SliceInfo<[SliceInfoElem; n], Din, Dout>.

Examples

SliceInfoElem::Index(a) is the index a. It can also be created with SliceInfoElem::from(a). The Python equivalent is [a]. The macro equivalent is s![a].

SliceInfoElem::Slice { start: 0, end: None, step: 1 } is the full range of an axis. It can also be created with SliceInfoElem::from(..). The Python equivalent is [:]. The macro equivalent is s![..].

SliceInfoElem::Slice { start: a, end: Some(b), step: 2 } is every second element from a until b. It can also be created with SliceInfoElem::from(Slice::from(a..b).step_by(2)). The Python equivalent is [a:b:2]. The macro equivalent is s![a..b;2].

SliceInfoElem::Slice { start: a, end: None, step: -1 } is every element, from a until the end, in reverse order. It can also be created with SliceInfoElem::from(Slice::from(a..).step_by(-1)). The Python equivalent is [a::-1]. The macro equivalent is s![a..;-1].

SliceInfoElem::NewAxis is a new axis of length 1. It can also be created with SliceInfoElem::from(NewAxis). The Python equivalent is [np.newaxis]. The macro equivalent is s![NewAxis].

Variants

Slice

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.

Fields of Slice

start: isizeend: Option<isize>step: isize
Index(isize)

A single index.

NewAxis

A new axis of length 1.

Implementations

impl SliceInfoElem[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 is_new_axis(&self) -> bool[src]

Returns true if self is a NewAxis value.

Trait Implementations

impl Clone for SliceInfoElem[src]

impl Copy for SliceInfoElem[src]

impl Debug for SliceInfoElem[src]

impl Display for SliceInfoElem[src]

impl Eq for SliceInfoElem[src]

impl From<NewAxis> for SliceInfoElem[src]

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

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

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

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

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

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

impl From<RangeFull> for SliceInfoElem[src]

impl From<RangeInclusive<i32>> for SliceInfoElem[src]

impl From<RangeInclusive<isize>> for SliceInfoElem[src]

impl From<RangeInclusive<usize>> for SliceInfoElem[src]

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

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

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

impl From<RangeToInclusive<i32>> for SliceInfoElem[src]

impl From<RangeToInclusive<isize>> for SliceInfoElem[src]

impl From<RangeToInclusive<usize>> for SliceInfoElem[src]

impl From<Slice> for SliceInfoElem[src]

impl From<i32> for SliceInfoElem[src]

impl From<isize> for SliceInfoElem[src]

impl From<usize> for SliceInfoElem[src]

impl Hash for SliceInfoElem[src]

impl PartialEq<SliceInfoElem> for SliceInfoElem[src]

impl StructuralEq for SliceInfoElem[src]

impl StructuralPartialEq for SliceInfoElem[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> Pointable for T

type Init = T

The type for initializers.

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

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.