[][src]Struct seqalign::Matrix

pub struct Matrix<T> { /* fields omitted */ }

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 10

Implementations

impl<T> Matrix<T> where
    T: Default
[src]

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]

type Output = T

The returned type after indexing.

impl<T> IndexMut<(usize, usize)> for Matrix<T> where
    T: Default
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Matrix<T> where
    T: RefUnwindSafe

impl<T> Send for Matrix<T> where
    T: Send

impl<T> Sync for Matrix<T> where
    T: Sync

impl<T> Unpin for Matrix<T> where
    T: Unpin

impl<T> UnwindSafe for Matrix<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[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]

impl<T, U> IntoPy<U> for T where
    U: FromPy<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.