Skip to main content

Vec2D

Struct Vec2D 

Source
pub struct Vec2D<T> { /* private fields */ }
Expand description

A row-major contiguous two-dimensional array.

Implementations§

Source§

impl<T> Vec2D<T>

Source

pub fn new() -> Self

Construct a new empty Vec2D

Source

pub fn from_vec(data: Vec<T>, n_columns: usize) -> Self

Take ownership of a Vec<T> and reinterpret as two-dimensional data.

Panics if data.len() is not an integer multiple of n_columns.

Source

pub fn n_cols(&self) -> usize

Return number of columns

Source

pub fn n_rows(&self) -> usize

Return number of rows

Source

pub fn iter<'a>(&'a self) -> Chunks<'a, T>

Iterate over rows

Source§

impl<T: Clone> Vec2D<T>

Source

pub fn from_slice(x: &[T], n_columns: usize) -> Vec2D<T>

Copy data from a slice and reinterpret as two-dimensional.

Panics if x.len() is not an integer multiple of n_columns.

Trait Implementations§

Source§

impl<T: Debug> Debug for Vec2D<T>

Source§

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

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

impl<T> Index<(usize, usize)> for Vec2D<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, (r, c): (usize, usize)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> Index<usize> for Vec2D<T>

Source§

type Output = [T]

The returned type after indexing.
Source§

fn index(&self, idx: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a Vec2D<T>

Source§

type Item = &'a [T]

The type of the elements being iterated over.
Source§

type IntoIter = Chunks<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Vec2D<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for Vec2D<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for Vec2D<T>
where Vec<T>: Send,

§

impl<T> Sync for Vec2D<T>
where Vec<T>: Sync,

§

impl<T> Unpin for Vec2D<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for Vec2D<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Vec2D<T>
where Vec<T>: 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.