pub struct InlineDynamicArray<const TCAPACITY: usize, T, TAllocator>where
T: Sized,
TAllocator: Allocator,{ /* private fields */ }Expand description
Represents a dynamic array, where first TCAPACITY items are inlined in the struct itself.
In other words, this array allocates memory only when its length exceeds TCAPACITY. In which
case it allocates data on heap, and becomes a slightly less efficient variant of
DynamicArray.
Similarly to DynamicArray this struct resizes the
underlying buffer by multiplying capacity by 3/2.
Implementations§
Source§impl<const TCAPACITY: usize, T, TAllocator> InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
Sourcepub fn new() -> Selfwhere
TAllocator: Default,
pub fn new() -> Selfwhere
TAllocator: Default,
Creates a new empty InlineDynamicArray with the default TAllocator.
Sourcepub const fn with_allocator(allocator: TAllocator) -> Self
pub const fn with_allocator(allocator: TAllocator) -> Self
Creates a new empty InlineDynamicArray with the given TAllocator.
Sourcepub fn with_capacity(capacity: Length) -> Result<Self, ArrayError>where
TAllocator: Default,
pub fn with_capacity(capacity: Length) -> Result<Self, ArrayError>where
TAllocator: Default,
Creates a new InlineDynamicArray with the default TAllocator. This method allocates memory
if capacity exceeds TCAPACITY.
§Errors
For details see ArrayError.
Sourcepub fn with_capacity_and_allocator(
capacity: Length,
allocator: TAllocator,
) -> Result<Self, ArrayError>
pub fn with_capacity_and_allocator( capacity: Length, allocator: TAllocator, ) -> Result<Self, ArrayError>
Creates a new InlineDynamicArray with the given TAllocator. This method allocates memory
if capacity exceeds TCAPACITY.
§Errors
For details see ArrayError.
Trait Implementations§
Source§impl<const TCAPACITY: usize, T, TAllocator> AsMut<[T]> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> AsMut<[T]> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
TAllocator: Allocator,
Source§impl<const TCAPACITY: usize, T, TAllocator> AsRef<[T]> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> AsRef<[T]> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
TAllocator: Allocator,
Source§impl<const TCAPACITY: usize, T, TAllocator> Borrow<[T]> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> Borrow<[T]> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
TAllocator: Allocator,
Source§impl<const TCAPACITY: usize, T, TAllocator> BorrowMut<[T]> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> BorrowMut<[T]> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
TAllocator: Allocator,
Source§fn borrow_mut(&mut self) -> &mut [T]
fn borrow_mut(&mut self) -> &mut [T]
Source§impl<const TCAPACITY: usize, T, TAllocator> Clone for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: TryClone,
TAllocator: Allocator + TryClone,
impl<const TCAPACITY: usize, T, TAllocator> Clone for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: TryClone,
TAllocator: Allocator + TryClone,
Source§impl<const TCAPACITY: usize, T, TAllocator> Debug for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> Debug for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
Source§impl<const TCAPACITY: usize, T, TAllocator> Default for InlineDynamicArray<TCAPACITY, T, TAllocator>
impl<const TCAPACITY: usize, T, TAllocator> Default for InlineDynamicArray<TCAPACITY, T, TAllocator>
Source§impl<'de, const CAPACITY: usize, T: Deserialize<'de>, TAllocator: Allocator + Default> Deserialize<'de> for InlineDynamicArray<CAPACITY, T, TAllocator>
Available on crate feature serde only.
impl<'de, const CAPACITY: usize, T: Deserialize<'de>, TAllocator: Allocator + Default> Deserialize<'de> for InlineDynamicArray<CAPACITY, T, TAllocator>
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<const TCAPACITY: usize, T, TAllocator> Drop for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> Drop for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> Eq for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Eq,
TAllocator: Allocator,
Source§impl<const TCAPACITY: usize, T, TAllocator> Hash for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Hash,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> Hash for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Hash,
TAllocator: Allocator,
Source§impl<const TCAPACITY: usize, T, TAllocator> ImmutableArray<T> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> ImmutableArray<T> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
Source§impl<const TCAPACITY: usize, T, TAllocator> Index<Length> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> Index<Length> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
Source§impl<const TCAPACITY: usize, T, TAllocator> MutableArray<T> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> MutableArray<T> for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized,
TAllocator: Allocator,
Source§fn try_push_array<const TSIZE: usize>(
&mut self,
arr: [T; TSIZE],
) -> Result<(), ArrayError>
fn try_push_array<const TSIZE: usize>( &mut self, arr: [T; TSIZE], ) -> Result<(), ArrayError>
Source§fn try_push_slice(&mut self, slice: &[T]) -> Result<(), ArrayTryCloneError>where
T: TryClone,
fn try_push_slice(&mut self, slice: &[T]) -> Result<(), ArrayTryCloneError>where
T: TryClone,
Source§fn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>
fn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>
Source§fn try_push(&mut self, value: T) -> Result<(), ArrayError>
fn try_push(&mut self, value: T) -> Result<(), ArrayError>
Source§fn push_array<const TSIZE: usize>(&mut self, arr: [T; TSIZE])
fn push_array<const TSIZE: usize>(&mut self, arr: [T; TSIZE])
Source§fn push_slice(&mut self, slice: &[T])where
T: TryClone,
fn push_slice(&mut self, slice: &[T])where
T: TryClone,
Source§impl<const TCAPACITY: usize, T, TAllocator, Rhs> PartialEq<Rhs> for InlineDynamicArray<TCAPACITY, T, TAllocator>
impl<const TCAPACITY: usize, T, TAllocator, Rhs> PartialEq<Rhs> for InlineDynamicArray<TCAPACITY, T, TAllocator>
Source§impl<const TCAPACITY: usize, T, TAllocator> ReprC for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized + ReprC,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> ReprC for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: Sized + ReprC,
TAllocator: Allocator,
impl<const TCAPACITY: usize, T, TAllocator> Send for InlineDynamicArray<TCAPACITY, T, TAllocator>
Source§impl<const CAPACITY: usize, T: Serialize, TAllocator: Allocator> Serialize for InlineDynamicArray<CAPACITY, T, TAllocator>
Available on crate feature serde only.
impl<const CAPACITY: usize, T: Serialize, TAllocator: Allocator> Serialize for InlineDynamicArray<CAPACITY, T, TAllocator>
serde only.impl<const TCAPACITY: usize, T, TAllocator> Sync for InlineDynamicArray<TCAPACITY, T, TAllocator>
Source§impl<const TCAPACITY: usize, T, TAllocator> TryClone for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: TryClone,
TAllocator: Allocator + TryClone,
impl<const TCAPACITY: usize, T, TAllocator> TryClone for InlineDynamicArray<TCAPACITY, T, TAllocator>where
T: TryClone,
TAllocator: Allocator + TryClone,
Source§fn try_clone(&self) -> Result<Self, Self::Error>
fn try_clone(&self) -> Result<Self, Self::Error>
Tries to clone the array. This is a perfect clone, with exactly the same capacity.
§Errors
For details see ArrayError.