[−][src]Trait crabsformer::prelude::Slice
Numeric vector slice operation
Associated Types
Loading content...Required methods
fn slice(&self, index: Idx) -> Self::Output
Performs the slicing (container.slice[index]
) operation.
It returns new numeric vector with the sliced elements.
Implementors
impl<T> Slice<Range<usize>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
Implements sub-numeric vector slicing with syntax
x.slice(begin .. end)
.
Returns a new numeric content that have elements of
the given numeric vector from the range [begin
..end
).
This operation is O(1)
.
Panics
Requires that begin <= end
and end <= len
where len
is the
length of the numeric vector. Otherwise it will panic.
Examples
let x = vector![3, 1, 2, 3]; // Range assert_eq!(x.slice(0..1), vector![3]); // RangeTo assert_eq!(x.slice(..2), vector![3, 1]); // RangeFrom assert_eq!(x.slice(2..), vector![2, 3]); // RangeFull assert_eq!(x.slice(..), vector![3, 1, 2, 3]); // RangeInclusive assert_eq!(x.slice(0..=1), vector![3, 1]); // RangeToInclusive assert_eq!(x.slice(..=2), vector![3, 1, 2]);
impl<T> Slice<RangeFrom<usize>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
impl<T> Slice<RangeFull> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
impl<T> Slice<RangeInclusive<usize>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
impl<T> Slice<RangeTo<usize>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
impl<T> Slice<RangeToInclusive<usize>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,