Struct Index

Source
pub struct Index {
    pub row: usize,
    pub col: usize,
}
Expand description

A structure representing the index of an element in a Matrix<T>.

Refer to SingleElementIndex for more information.

Fields§

§row: usize

The row index of the element.

§col: usize

The column index of the element.

Implementations§

Source§

impl Index

Source

pub fn new(row: usize, col: usize) -> Self

Creates a new Index.

§Examples
use matreex::Index;

let index = Index::new(2, 3);
assert_eq!(index.row, 2);
assert_eq!(index.col, 3);
Source

pub fn swap(&mut self) -> &mut Self

Swaps the row and column indices.

§Examples
use matreex::Index;

let mut index = Index::new(2, 3);
index.swap();
assert_eq!(index, Index::new(3, 2));

Trait Implementations§

Source§

impl Clone for Index

Source§

fn clone(&self) -> Index

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 Index

Source§

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

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

impl Default for Index

Source§

fn default() -> Index

Returns the “default value” for a type. Read more
Source§

impl From<[usize; 2]> for Index

Source§

fn from(value: [usize; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<(usize, usize)> for Index

Source§

fn from(value: (usize, usize)) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Index

Source§

fn eq(&self, other: &Index) -> 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 SingleElementIndex for Index

Source§

fn row(&self) -> usize

The row index of the element.
Source§

fn col(&self) -> usize

The column index of the element.
Source§

impl Copy for Index

Source§

impl Eq for Index

Source§

impl StructuralPartialEq for Index

Auto Trait Implementations§

§

impl Freeze for Index

§

impl RefUnwindSafe for Index

§

impl Send for Index

§

impl Sync for Index

§

impl Unpin for Index

§

impl UnwindSafe for Index

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, I> MatrixIndex<T> for I

Source§

type Output = T

The output type returned by methods.
Source§

fn is_out_of_bounds(&self, matrix: &Matrix<T>) -> bool

Returns true if the index is out of bounds for the given matrix.
Source§

fn get( self, matrix: &Matrix<T>, ) -> Result<&<I as MatrixIndex<T>>::Output, Error>

Returns a shared reference to the output at this location, if in bounds. Read more
Source§

fn get_mut( self, matrix: &mut Matrix<T>, ) -> Result<&mut <I as MatrixIndex<T>>::Output, Error>

Returns a mutable reference to the output at this location, if in bounds. Read more
Source§

unsafe fn get_unchecked( self, matrix: *const Matrix<T>, ) -> *const <I as MatrixIndex<T>>::Output

Returns a pointer to the output at this location, without performing any bounds checking. Read more
Source§

unsafe fn get_unchecked_mut( self, matrix: *mut Matrix<T>, ) -> *mut <I as MatrixIndex<T>>::Output

Returns a mutable pointer to the output at this location, without performing any bounds checking. Read more
Source§

fn ensure_in_bounds(&self, matrix: &Matrix<T>) -> Result<&Self>

Ensures the index is in bounds for the given matrix. Read more
Source§

fn index(self, matrix: &Matrix<T>) -> &Self::Output

Returns a shared reference to the output at this location. Read more
Source§

fn index_mut(self, matrix: &mut Matrix<T>) -> &mut Self::Output

Returns a mutable reference to the output at this location. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.