[−][src]Struct seqalign::Matrix
A wrapper for a 2D vector.
The Matrix struct accepts any type that implements the Default trait.
Examples
let rows = 10;
let cols = 10;
let mut m : Matrix<isize> = Matrix::new(rows, cols);
m[(0, 0)] = 3;
m[(0, 1)] = 5;
let num = m[(0, 0)];
let score = m.get(0, 1).expect("Error getting an immutable reference");
// *score = 34; Uncommenting this line will result as an error
let score = m.get_mut(0, 1).expect("Error getting a mutable reference");
*score = 10; // now m[(0, 1)] is equal to 10Implementations
impl<T> Matrix<T> where
T: Default, [src]
T: Default,
pub fn new(n: usize, m: usize) -> Matrix<T>[src]
Creates a new instance of Matrix filling it with the default value of the type T
Example
let mut m : Matrix<isize> = Matrix::new(10, 20);
// Now the matrix is filled entirely with the default value
// of the isize primitive type which is 0.pub fn get(&self, i: usize, j: usize) -> Option<&T>[src]
Get an immutable reference of the value on matrix[(i, j)]
Return: An Option that returns None if the index is out of range
or the reference within a Some variant.
pub fn get_mut(&mut self, i: usize, j: usize) -> Option<&mut T>[src]
Get an mutable reference of the value on matrix[(i, j)]
Return: An Option that returns None if the index is out of range
or the reference within a Some variant.
Trait Implementations
impl<T> Index<(usize, usize)> for Matrix<T> where
T: Default, [src]
T: Default,
type Output = T
The returned type after indexing.
fn index(&self, idx: (usize, usize)) -> &Self::Output[src]
impl<T> IndexMut<(usize, usize)> for Matrix<T> where
T: Default, [src]
T: Default,
Auto Trait Implementations
impl<T> RefUnwindSafe for Matrix<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Matrix<T> where
T: Send,
T: Send,
impl<T> Sync for Matrix<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Matrix<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Matrix<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> FromPy<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> IntoPy<U> for T where
U: FromPy<T>, [src]
U: FromPy<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,