DynamicArray

Struct DynamicArray 

Source
pub struct DynamicArray<T, TAllocator: Allocator> { /* private fields */ }
Expand description

A #[repr(C)] variant of the standard vec struct.

Functionally the same, but with slightly different functionalities.

Implementations§

Source§

impl<T, TAllocator: Allocator> DynamicArray<T, TAllocator>

Source

pub fn new() -> Self

Creates a new, empty DynamicArray.

Source

pub const fn with_allocator(allocator: TAllocator) -> Self

Creates a new, empty DynamicArray with an allocator.

Source

pub fn with_capacity_and_allocator( capacity: Length, allocator: TAllocator, ) -> Result<Self, ArrayError>

Creates a new DynamicArray with capacity and allocator. This allocates memory only when capacity > 0.

§Errors

For details see ArrayError.

Source

pub fn with_capacity(capacity: Length) -> Result<Self, ArrayError>

Creates a new DynamicArray with capacity and the default allocator. This allocates memory only when capacity > 0.

§Errors

For details see ArrayError.

Trait Implementations§

Source§

impl<T, TAllocator: Allocator> AsMut<[T]> for DynamicArray<T, TAllocator>

Source§

fn as_mut(&mut self) -> &mut [T]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T, TAllocator: Allocator> AsRef<[T]> for DynamicArray<T, TAllocator>

Source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, TAllocator: Allocator> Borrow<[T]> for DynamicArray<T, TAllocator>

Source§

fn borrow(&self) -> &[T]

Immutably borrows from an owned value. Read more
Source§

impl<T, TAllocator: Allocator> BorrowMut<[T]> for DynamicArray<T, TAllocator>

Source§

fn borrow_mut(&mut self) -> &mut [T]

Mutably borrows from an owned value. Read more
Source§

impl<T: Clone, TAllocator: Allocator> Clone for DynamicArray<T, TAllocator>

Source§

fn clone(&self) -> Self

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<T: Debug, TAllocator: Debug + Allocator> Debug for DynamicArray<T, TAllocator>

Source§

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

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

impl<T, TAllocator: Allocator> Default for DynamicArray<T, TAllocator>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, TAllocator: Allocator> Drop for DynamicArray<T, TAllocator>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: Hash, TAllocator: Allocator> Hash for DynamicArray<T, TAllocator>

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<T, TAllocator: Allocator> ImmutableArray<T> for DynamicArray<T, TAllocator>

Source§

fn length(&self) -> Length

Returns array’s length as [Length].
Source§

fn capacity(&self) -> Length

Returns the current capacity for holding items in the array.
Source§

fn as_slice(&self) -> &[T]

Represents the array as immutable slice.
Source§

fn is_empty(&self) -> bool

Returns true if array is empty, false otherwise. Should be consistent with self.length() == Length::ZERO check.
Source§

impl<T, TAllocator: Allocator> Index<Length> for DynamicArray<T, TAllocator>

Source§

type Output = T

The returned type after indexing.
Source§

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

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

impl<T, TAllocator: Allocator> IndexMut<Length> for DynamicArray<T, TAllocator>

Source§

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

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

impl<T, TAllocator: Allocator> MutableArray<T> for DynamicArray<T, TAllocator>

Source§

fn try_push_array<const TSIZE: usize>( &mut self, arr: [T; TSIZE], ) -> Result<(), ArrayError>

Pushes raw array to the array. Read more
Source§

fn try_push_slice(&mut self, slice: &[T]) -> Result<(), ArrayError>
where T: Clone,

Pushes slice to the array. This method requires Clone trait on T. Read more
Source§

fn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>

Removes element from the top of the array. Read more
Source§

fn as_slice_mut(&mut self) -> &mut [T]

Represents the array as mutable slice.
Source§

fn pop(&mut self) -> T

Removes element from the top of the array. Read more
Source§

fn try_push(&mut self, value: T) -> Result<(), ArrayError>

Pushes a single element to the array. Read more
Source§

fn push_array<const TSIZE: usize>(&mut self, arr: [T; TSIZE])

Pushes raw array to the array. Read more
Source§

fn push_slice(&mut self, slice: &[T])
where T: Clone,

Pushes raw slice to the array. This method requires Clone trait on T. Read more
Source§

fn push(&mut self, value: T)

Pushes a single element to the array. Read more
Source§

impl<T: PartialEq, TAllocator: Allocator> PartialEq for DynamicArray<T, TAllocator>

Source§

fn eq(&self, other: &Self) -> 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<T: Eq, TAllocator: Allocator> Eq for DynamicArray<T, TAllocator>

Auto Trait Implementations§

§

impl<T, TAllocator> Freeze for DynamicArray<T, TAllocator>
where TAllocator: Freeze,

§

impl<T, TAllocator> RefUnwindSafe for DynamicArray<T, TAllocator>
where TAllocator: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, TAllocator> !Send for DynamicArray<T, TAllocator>

§

impl<T, TAllocator> !Sync for DynamicArray<T, TAllocator>

§

impl<T, TAllocator> Unpin for DynamicArray<T, TAllocator>
where TAllocator: Unpin,

§

impl<T, TAllocator> UnwindSafe for DynamicArray<T, TAllocator>
where TAllocator: UnwindSafe, T: RefUnwindSafe,

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, 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.