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

source

pub fn new(start: usize, length: usize) -> IndexRange

Trait Implementations§

source§

impl Clone for IndexRange

source§

fn clone(&self) -> IndexRange

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for IndexRange

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

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§

fn from(range: [usize; 2]) -> IndexRange

Converts to this type from the input type.
source§

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§

fn from(range: (usize, usize)) -> IndexRange

Converts to this type from the input type.
source§

impl From<IndexRange> for Range<usize>

Converts from an IndexRange of start and length to a range of start..end

source§

fn from(range: IndexRange) -> Range<usize>

Converts to this type from the input type.
source§

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§

fn from(range: Range<usize>) -> IndexRange

Converts to this type from the input type.
source§

impl PartialEq<IndexRange> for IndexRange

source§

fn eq(&self, other: &IndexRange) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for IndexRange

source§

impl StructuralEq for IndexRange

source§

impl StructuralPartialEq for IndexRange

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere
    T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.