Struct NestedArray

Source
pub struct NestedArray<T, S, M, N> { /* private fields */ }
Expand description

An Array implemented as an array of arrays.

It contains a main Array of type M. Each element (nested array) of the main array is an Array of type N. The type of the elements of the nested arrays is T.

This type offers a flatted view of the elements in the nested arrays. Each time an element at a specified index is accessed, the index is decomposed in two indices (using S: Split), the first one is used to index the main array and the second one to index the nested array.

This type is interesting to implemented copy on write arrays. See CowNestedArray.

Trait Implementations§

Source§

impl<T, S, M, N> Array<T> for NestedArray<T, S, M, N>
where S: Split, M: Array<N>, N: Array<T> + Clone,

Source§

fn with_value(value: T, n: usize) -> Self
where T: Clone,

Creates a new array with n repeated value.
Source§

fn len(&self) -> usize

Returns the number of elements in the array.
Source§

unsafe fn get_unchecked(&self, index: usize) -> &T

Returns a reference to the element of the array at index, without doing bounds checking.
Source§

unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T

Returns a mutable reference to the element of the array at index, without doing bounds checking.
Source§

fn contains(&self, value: &T) -> bool
where T: PartialEq,

Returns true if the array contains value, false otherwise.
Source§

fn is_empty(&self) -> bool

Returns true if the length of the array is 0, otherwise false.
Source§

fn get(&self, index: usize) -> Option<&T>

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

fn get_mut(&mut self, index: usize) -> Option<&mut T>

Returns a mutable reference to the element of the array at index, or None if the index is out of bounds.
Source§

fn iter(&self) -> Iter<'_, T, Self>
where Self: Sized,

Returns a iterator over the array.
Source§

impl<T: Clone, S: Clone, M: Clone, N: Clone> Clone for NestedArray<T, S, M, N>

Source§

fn clone(&self) -> NestedArray<T, S, M, N>

Returns a copy 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<T, S, M, N> DynamicArray<T> for NestedArray<T, S, M, N>
where S: Split, M: DynamicArray<N>, N: DynamicArray<T> + Clone,

Source§

fn with_capacity(capacity: usize) -> Self
where Self: Sized,

Creates a array with the specified capacity. Read more
Source§

fn capacity(&self) -> usize

Returns the capacity of the array.
Source§

unsafe fn set_len(&mut self, len: usize)

Change the length of the array.
Source§

fn reserve(&mut self, additional: usize)

Reserve capacity for at least additional more elements. Read more
Source§

unsafe fn push_unchecked(&mut self, value: T)

Write value to the end of the array and increment the length. Read more
Source§

fn push(&mut self, value: T)

Appends the value to the array. Read more
Source§

fn extend<I>(&mut self, iter: I)
where Self: Sized, I: IntoIterator<Item = T>,

Appends all elements of iter to the array. Read more
Source§

fn extend_from_slice(&mut self, other: &[T])
where T: Clone,

Appends all elements in a slice to the array. Read more
Source§

fn extend_with_element(&mut self, value: T, n: usize)
where T: Clone,

Extend the array by n additional clones of value. Read more
Source§

impl<T, S, M, N> Index<usize> for NestedArray<T, S, M, N>
where S: Split, M: Array<N>, N: Array<T> + Clone,

Source§

type Output = T

The returned type after indexing.
Source§

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

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

impl<T, S, M, N> IndexMut<usize> for NestedArray<T, S, M, N>
where S: Split, M: Array<N>, N: Array<T> + Clone,

Source§

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

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

Auto Trait Implementations§

§

impl<T, S, M, N> Freeze for NestedArray<T, S, M, N>
where M: Freeze, S: Freeze,

§

impl<T, S, M, N> RefUnwindSafe for NestedArray<T, S, M, N>

§

impl<T, S, M, N> Send for NestedArray<T, S, M, N>
where M: Send, S: Send, T: Send, N: Send,

§

impl<T, S, M, N> Sync for NestedArray<T, S, M, N>
where M: Sync, S: Sync, T: Sync, N: Sync,

§

impl<T, S, M, N> Unpin for NestedArray<T, S, M, N>
where M: Unpin, S: Unpin, T: Unpin, N: Unpin,

§

impl<T, S, M, N> UnwindSafe for NestedArray<T, S, M, N>

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.