[−][src]Enum ndarray::SliceOrIndex
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
SliceA 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
start: isize | |
end: Option<isize> | |
step: isize |
Index(isize)A single index.
Methods
impl SliceOrIndex[src]
impl SliceOrIndexpub fn is_slice(&self) -> bool[src]
pub fn is_slice(&self) -> boolReturns true if self is a Slice value.
pub fn is_index(&self) -> bool[src]
pub fn is_index(&self) -> boolReturns true if self is an Index value.
pub fn step_by(self, step: isize) -> Self[src]
pub fn step_by(self, step: isize) -> SelfReturns 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]
impl Debug for SliceOrIndexfn 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 SliceOrIndex[src]
impl PartialEq for SliceOrIndexfn eq(&self, other: &SliceOrIndex) -> bool[src]
fn eq(&self, other: &SliceOrIndex) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &SliceOrIndex) -> bool[src]
fn ne(&self, other: &SliceOrIndex) -> boolThis method tests for !=.
impl Eq for SliceOrIndex[src]
impl Eq for SliceOrIndeximpl Hash for SliceOrIndex[src]
impl Hash for SliceOrIndexfn 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 Copy for SliceOrIndex[src]
impl Copy for SliceOrIndeximpl Clone for SliceOrIndex[src]
impl Clone for SliceOrIndexfn clone(&self) -> Self[src]
fn clone(&self) -> SelfReturns 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 Display for SliceOrIndex[src]
impl Display for SliceOrIndexfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl From<Slice> for SliceOrIndex[src]
impl From<Slice> for SliceOrIndexfn from(s: Slice) -> SliceOrIndex[src]
fn from(s: Slice) -> SliceOrIndexPerforms the conversion.
impl From<isize> for SliceOrIndex[src]
impl From<isize> for SliceOrIndexfn from(r: isize) -> SliceOrIndex[src]
fn from(r: isize) -> SliceOrIndexPerforms the conversion.
impl From<Range<isize>> for SliceOrIndex[src]
impl From<Range<isize>> for SliceOrIndexfn from(r: Range<isize>) -> SliceOrIndex[src]
fn from(r: Range<isize>) -> SliceOrIndexPerforms the conversion.
impl From<RangeFrom<isize>> for SliceOrIndex[src]
impl From<RangeFrom<isize>> for SliceOrIndexfn from(r: RangeFrom<isize>) -> SliceOrIndex[src]
fn from(r: RangeFrom<isize>) -> SliceOrIndexPerforms the conversion.
impl From<RangeTo<isize>> for SliceOrIndex[src]
impl From<RangeTo<isize>> for SliceOrIndexfn from(r: RangeTo<isize>) -> SliceOrIndex[src]
fn from(r: RangeTo<isize>) -> SliceOrIndexPerforms the conversion.
impl From<usize> for SliceOrIndex[src]
impl From<usize> for SliceOrIndexfn from(r: usize) -> SliceOrIndex[src]
fn from(r: usize) -> SliceOrIndexPerforms the conversion.
impl From<Range<usize>> for SliceOrIndex[src]
impl From<Range<usize>> for SliceOrIndexfn from(r: Range<usize>) -> SliceOrIndex[src]
fn from(r: Range<usize>) -> SliceOrIndexPerforms the conversion.
impl From<RangeFrom<usize>> for SliceOrIndex[src]
impl From<RangeFrom<usize>> for SliceOrIndexfn from(r: RangeFrom<usize>) -> SliceOrIndex[src]
fn from(r: RangeFrom<usize>) -> SliceOrIndexPerforms the conversion.
impl From<RangeTo<usize>> for SliceOrIndex[src]
impl From<RangeTo<usize>> for SliceOrIndexfn from(r: RangeTo<usize>) -> SliceOrIndex[src]
fn from(r: RangeTo<usize>) -> SliceOrIndexPerforms the conversion.
impl From<i32> for SliceOrIndex[src]
impl From<i32> for SliceOrIndexfn from(r: i32) -> SliceOrIndex[src]
fn from(r: i32) -> SliceOrIndexPerforms the conversion.
impl From<Range<i32>> for SliceOrIndex[src]
impl From<Range<i32>> for SliceOrIndexfn from(r: Range<i32>) -> SliceOrIndex[src]
fn from(r: Range<i32>) -> SliceOrIndexPerforms the conversion.
impl From<RangeFrom<i32>> for SliceOrIndex[src]
impl From<RangeFrom<i32>> for SliceOrIndexfn from(r: RangeFrom<i32>) -> SliceOrIndex[src]
fn from(r: RangeFrom<i32>) -> SliceOrIndexPerforms the conversion.
impl From<RangeTo<i32>> for SliceOrIndex[src]
impl From<RangeTo<i32>> for SliceOrIndexfn from(r: RangeTo<i32>) -> SliceOrIndex[src]
fn from(r: RangeTo<i32>) -> SliceOrIndexPerforms the conversion.
impl From<RangeFull> for SliceOrIndex[src]
impl From<RangeFull> for SliceOrIndexfn from(_: RangeFull) -> SliceOrIndex[src]
fn from(_: RangeFull) -> SliceOrIndexPerforms the conversion.
Auto Trait Implementations
impl Send for SliceOrIndex
impl Send for SliceOrIndeximpl Sync for SliceOrIndex
impl Sync for SliceOrIndexBlanket 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> ToString for T where
T: Display + ?Sized, [src]
impl<T> ToString for T where
T: Display + ?Sized, impl<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