[−][src]Struct ndarray::Slice
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.
See also the s![] macro.
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]
impl Slicepub fn new(start: isize, end: Option<isize>, step: isize) -> Slice[src]
pub fn new(start: isize, end: Option<isize>, step: isize) -> SliceCreate 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.)
pub fn step_by(self, step: isize) -> Self[src]
pub fn step_by(self, step: isize) -> SelfCreate 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 Copy for Sliceimpl Clone for Slice[src]
impl Clone for Slicefn clone(&self) -> Slice[src]
fn clone(&self) -> SliceReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Debug for Slice[src]
impl Debug for Slicefn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl PartialEq for Slice[src]
impl PartialEq for Slicefn eq(&self, other: &Slice) -> bool[src]
fn eq(&self, other: &Slice) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Slice) -> bool[src]
fn ne(&self, other: &Slice) -> boolThis method tests for !=.
impl Eq for Slice[src]
impl Eq for Sliceimpl Hash for Slice[src]
impl Hash for Slicefn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash<__H: Hasher>(&self, state: &mut __H)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]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl From<Range<isize>> for Slice[src]
impl From<Range<isize>> for Sliceimpl From<RangeFrom<isize>> for Slice[src]
impl From<RangeFrom<isize>> for Sliceimpl From<RangeTo<isize>> for Slice[src]
impl From<RangeTo<isize>> for Sliceimpl From<Range<usize>> for Slice[src]
impl From<Range<usize>> for Sliceimpl From<RangeFrom<usize>> for Slice[src]
impl From<RangeFrom<usize>> for Sliceimpl From<RangeTo<usize>> for Slice[src]
impl From<RangeTo<usize>> for Sliceimpl From<Range<i32>> for Slice[src]
impl From<Range<i32>> for Sliceimpl From<RangeFrom<i32>> for Slice[src]
impl From<RangeFrom<i32>> for Sliceimpl From<RangeTo<i32>> for Slice[src]
impl From<RangeTo<i32>> for Sliceimpl From<RangeFull> for Slice[src]
impl From<RangeFull> for Sliceimpl From<Slice> for SliceOrIndex[src]
impl From<Slice> for SliceOrIndexfn from(s: Slice) -> SliceOrIndex[src]
fn from(s: Slice) -> SliceOrIndexPerforms the conversion.
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 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]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 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