Struct visioncortex::Field [−][src]
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]
T: Default,
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]
T: Clone,
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]
Auto Trait Implementations
impl<T> RefUnwindSafe for Field<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Field<T> where
T: Send,
T: Send,
impl<T> Sync for Field<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Field<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Field<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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,