Bounds

Struct Bounds 

Source
pub struct Bounds<I> {
    pub offset: I,
    pub extent: I,
}
Expand description

Bounds associated with an index type.

This is a description of the bounds of a multidimensional array, through the definition of an offset and an extent. Bounds can also be used to describe the bounds of an index list, which can be used to ensure that a collection of indices are all in bounds, and therefore bounds checks can be eliminated up front, prior to iteration.

In general, Bounds is expected to be used with either integers like usize for one-dimensional arrays or tuples like (usize, usize) for multidimensional arrays. For data structures, the offset is typically zero along each dimension, and the extent describes the “length” of the array along each dimension.

Offset primarily exists in order for index lists to more tightly describe their bounds, which can be used, for example, to ensure that index lists with disjoint bounds contain disjoint indices. However, a data structure can have non-zero offset.

Fields§

§offset: I

The offset of the bounds.

§extent: I

The extent of the bounds.

Implementations§

Source§

impl<I> Bounds<I>

Source

pub fn zip<I2>(self, other: Bounds<I2>) -> Bounds<(I, I2)>

Zips the offset and extent of two Bounds instances.

Source§

impl<I: RecordIndex> Bounds<I>

Source

pub fn contains_bounds(&self, other: &Bounds<I>) -> bool

Check if these bounds contain other.

Source

pub fn contains_index(&self, index: I) -> bool

Check if these bounds contain the given index.

Source

pub fn enclose_index(&mut self, index: I)

Expand these bounds — if needed — so that the given index is contained in the updated bounds.

Source

pub fn new_empty() -> Self

Constructs empty bounds (zero extent along each dimension).

Source

pub fn bounds_for_index(index: I) -> Self

Constructs bounds large enough to hold only exactly the given index.

Trait Implementations§

Source§

impl<I: Clone> Clone for Bounds<I>

Source§

fn clone(&self) -> Bounds<I>

Returns a duplicate 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<I: Debug> Debug for Bounds<I>

Source§

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

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

impl<I: PartialEq> PartialEq for Bounds<I>

Source§

fn eq(&self, other: &Bounds<I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I: Copy> Copy for Bounds<I>

Source§

impl<I: Eq> Eq for Bounds<I>

Source§

impl<I> StructuralPartialEq for Bounds<I>

Auto Trait Implementations§

§

impl<I> Freeze for Bounds<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for Bounds<I>
where I: RefUnwindSafe,

§

impl<I> Send for Bounds<I>
where I: Send,

§

impl<I> Sync for Bounds<I>
where I: Sync,

§

impl<I> Unpin for Bounds<I>
where I: Unpin,

§

impl<I> UnwindSafe for Bounds<I>
where I: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.