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
start: isize
end: Option<isize>
step: isize
Methods
impl Slice[src]
fn new(start: isize, end: Option<isize>, step: isize) -> Slice[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.)
fn step_by(self, step: isize) -> Self[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]
fn clone(&self) -> Slice[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Debug for Slice[src]
impl PartialEq for Slice[src]
fn eq(&self, __arg_0: &Slice) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &Slice) -> bool[src]
This method tests for !=.
impl Eq for Slice[src]
impl Hash for Slice[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more