Struct easy_ml::matrices::views::IndexRange
source · pub struct IndexRange { /* private fields */ }
Expand description
A range bounded between start
inclusive and start + length
exclusive.
Examples
Converting between Range and IndexRange.
use std::ops::Range;
use easy_ml::matrices::views::IndexRange;
assert_eq!(IndexRange::new(3, 2), (3..5).into());
assert_eq!(IndexRange::new(1, 5), (1..6).into());
assert_eq!(IndexRange::new(0, 4), (0..4).into());
Creating a Range
use easy_ml::matrices::views::IndexRange;
let range = IndexRange::new(3, 2);
let also_range: IndexRange = (3, 2).into();
let also_also_range: IndexRange = [3, 2].into();
Implementations§
source§impl IndexRange
impl IndexRange
pub fn new(start: usize, length: usize) -> IndexRange
Trait Implementations§
source§impl Clone for IndexRange
impl Clone for IndexRange
source§fn clone(&self) -> IndexRange
fn clone(&self) -> IndexRange
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for IndexRange
impl Debug for IndexRange
source§impl From<[usize; 2]> for IndexRange
impl From<[usize; 2]> for IndexRange
Converts from an array of start and length to an IndexRange
NOTE: In previous versions (<=1.8.1), this was erroneously implemented as conversion from an array of start and end, not start and length as documented.
source§impl From<(usize, usize)> for IndexRange
impl From<(usize, usize)> for IndexRange
Converts from a tuple of start and length to an IndexRange
NOTE: In previous versions (<=1.8.1), this was erroneously implemented as conversion from a tuple of start and end, not start and length as documented.
source§impl From<IndexRange> for Range<usize>
impl From<IndexRange> for Range<usize>
Converts from an IndexRange of start and length to a range of start..end
source§impl From<Range<usize>> for IndexRange
impl From<Range<usize>> for IndexRange
Converts from a range of start..end to an IndexRange of start and length
NOTE: In previous versions (<=1.8.1) this did not saturate when attempting to subtract the start of the range from the end to calculate the length. It will now correctly produce an IndexRange with a length of 0 if the end is before or equal to the start.
source§impl PartialEq<IndexRange> for IndexRange
impl PartialEq<IndexRange> for IndexRange
source§fn eq(&self, other: &IndexRange) -> bool
fn eq(&self, other: &IndexRange) -> bool
self
and other
values to be equal, and is used
by ==
.