Struct visioncortex::Field[][src]

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

Vec<T> that represents a 2D field

Implementations

impl<T> Field<T>[src]

The base implementation of Field

pub fn with_vec(width: usize, height: usize, data: Vec<T>) -> Option<Self>[src]

Constructs a height by width field with data. Returns None if the size of data does not equal to height * width.

pub fn width(&self) -> usize[src]

Returns the width of the field.

pub fn height(&self) -> usize[src]

Returns the height of the field.

pub fn peek(&self, index: usize) -> Option<&T>[src]

Returns a reference to an element.

pub fn peek_mut(&mut self, index: usize) -> Option<&mut T>[src]

Returns a mutable reference to an element.

pub fn replace(&mut self, index: usize, value: T) -> Option<T>[src]

Replaces an element with value and returns the element.

pub fn locate(&self, index: usize) -> (usize, usize)[src]

Returns the xy-coordinates representation of an index in the field.

pub fn index_at(&self, x: usize, y: usize) -> usize[src]

Returns the index of a xy-coordinates representation in the field.

pub fn iter(&self) -> impl Iterator + '_[src]

pub fn iter_mut(&mut self) -> impl Iterator + '_[src]

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

pub fn with_default(width: usize, height: usize) -> Self[src]

Constructs a height by width field, with each slot filled with the default value of its element type.

impl<T> Field<T> where
    T: Clone
[src]

pub fn with_initial(width: usize, height: usize, value: T) -> Self[src]

Constructs a height by width field, with each slot filled with value.

pub fn get(&self, index: usize) -> Option<T>[src]

Returns a copy of an element.

pub fn set(&mut self, index: usize, value: &T)[src]

Assigns a copy of a value to a slot.

Trait Implementations

impl<T: Clone> Clone for Field<T>[src]

impl<T: Default> Default for Field<T>[src]

impl<T> IntoIterator for Field<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

Auto Trait Implementations

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

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

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

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

impl<T> UnwindSafe for Field<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, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.