Struct ndarray::Slice [] [src]

pub struct Slice {
    pub start: isize,
    pub end: Option<isize>,
    pub step: isize,
}

A slice (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.

Examples

Slice::new(0, None, 1) is the full range of an axis. It can also be created with Slice::from(..). The Python equivalent is [:].

Slice::new(a, b, 2) is every second element from a until b. It can also be created with Slice::from(a..b).step_by(2). The Python equivalent is [a:b:2].

Slice::new(a, None, -1) is every element, from a until the end, in reverse order. It can also be created with Slice::from(a..).step_by(-1). The Python equivalent is [a::-1].

Fields

Methods

impl Slice
[src]

[src]

Create a new Slice with the given extents.

See also the From impls, converting from ranges; for example Slice::from(i..) or Slice::from(j..k).

step must be nonzero. (This method checks with a debug assertion that step is not zero.)

[src]

Create a new Slice 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 Copy for Slice
[src]

impl Clone for Slice
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Slice
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for Slice
[src]

[src]

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

[src]

This method tests for !=.

impl Eq for Slice
[src]

impl Hash for Slice
[src]

[src]

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

1.3.0
[src]

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

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

impl From<RangeFull> for Slice
[src]

[src]

Performs the conversion.