Array

Struct Array 

Source
pub struct Array<S, V, T, L = <V as Vector<S>>::DefaultLayout>
where S: Integer, V: Vector<S>, L: Layout<S, V>,
{ /* private fields */ }
Expand description

An array indexed by points in a bounding box.

Implementations§

Source§

impl<S, V, T> Array<S, V, T, <V as Vector<S>>::DefaultLayout>
where S: Integer, V: Vector<S>,

Source

pub fn new(bbox: BBox<S, V>, d: T) -> Self
where T: Clone, usize: TryFrom<S>, <usize as TryFrom<S>>::Error: Debug, <S as TryFrom<usize>>::Error: Debug,

Creates a new array with the given bounding box that is filled with copies of a given element.

Source

pub fn with<F>(bbox: BBox<S, V>, f: F) -> Self
where F: FnMut(Point<S, V>) -> T, usize: TryFrom<S>, <usize as TryFrom<S>>::Error: Debug, <S as TryFrom<usize>>::Error: Debug,

Creates a new array with the given bounding box that is filled using a function which takes a location as input.

Source§

impl<S, V, T, L> Array<S, V, T, L>
where S: Integer, V: Vector<S>, L: Layout<S, V>,

Source

pub fn bbox(&self) -> BBox<S, V>

Returns the bounding box of the array.

Source

pub fn bounds(&self) -> BBox<S, V>

👎Deprecated: Use bbox instead.

Returns the bounding box of the array.

Source

pub fn get(&self, index: Point<S, V>) -> Option<&T>
where usize: TryFrom<S>, <usize as TryFrom<S>>::Error: Debug,

Returns a reference to the element at the index or None if the index is out of bounds.

Source

pub fn get_mut(&mut self, index: Point<S, V>) -> Option<&mut T>
where usize: TryFrom<S>, <usize as TryFrom<S>>::Error: Debug,

Returns a reference to the element at the index or None if the index is out of bounds.

Source

pub fn iter(&self) -> impl Iterator<Item = &T>
where usize: TryFrom<S>, <usize as TryFrom<S>>::Error: Debug,

Returns an iterator over the elements of the array.

Source§

impl<S, T> Array<S, Vec2d<S>, T>
where S: Integer,

Source

pub fn from_vec(v: Vec<Vec<T>>) -> Self
where T: Copy, <S as TryFrom<usize>>::Error: Debug, usize: TryFrom<S>, <usize as TryFrom<S>>::Error: Debug,

Creates a new array with the given bounds that is filled from a vector of vectors.

Trait Implementations§

Source§

impl<S, V, T: Clone, L> Clone for Array<S, V, T, L>
where S: Integer + Clone, V: Vector<S> + Clone, L: Layout<S, V> + Clone,

Source§

fn clone(&self) -> Array<S, V, T, L>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S, V, T: Debug, L> Debug for Array<S, V, T, L>
where S: Integer + Debug, V: Vector<S> + Debug, L: Layout<S, V> + Debug,

Source§

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

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

impl<S, V, T: Hash, L> Hash for Array<S, V, T, L>
where S: Integer + Hash, V: Vector<S> + Hash, L: Layout<S, V> + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<S, V, T, L> Index<Point<S, V>> for Array<S, V, T, L>
where S: Integer, V: Vector<S>, L: Layout<S, V>, usize: TryFrom<S>, <usize as TryFrom<S>>::Error: Debug,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: Point<S, V>) -> &T

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

impl<S, V, T, L> IndexMut<Point<S, V>> for Array<S, V, T, L>
where S: Integer, V: Vector<S>, L: Layout<S, V>, usize: TryFrom<S>, <usize as TryFrom<S>>::Error: Debug,

Source§

fn index_mut(&mut self, index: Point<S, V>) -> &mut T

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

impl<S, V, T: PartialEq, L> PartialEq for Array<S, V, T, L>
where S: Integer + PartialEq, V: Vector<S> + PartialEq, L: Layout<S, V> + PartialEq,

Source§

fn eq(&self, other: &Array<S, V, T, L>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S, V, T: Eq, L> Eq for Array<S, V, T, L>
where S: Integer + Eq, V: Vector<S> + Eq, L: Layout<S, V> + Eq,

Source§

impl<S, V, T, L> StructuralPartialEq for Array<S, V, T, L>
where S: Integer, V: Vector<S>, L: Layout<S, V>,

Auto Trait Implementations§

§

impl<S, V, T, L> Freeze for Array<S, V, T, L>
where L: Freeze,

§

impl<S, V, T, L> RefUnwindSafe for Array<S, V, T, L>

§

impl<S, V, T, L> Send for Array<S, V, T, L>
where L: Send, S: Send, V: Send, T: Send,

§

impl<S, V, T, L> Sync for Array<S, V, T, L>
where L: Sync, S: Sync, V: Sync, T: Sync,

§

impl<S, V, T, L> Unpin for Array<S, V, T, L>
where L: Unpin, S: Unpin, V: Unpin,

§

impl<S, V, T, L> UnwindSafe for Array<S, V, T, L>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.