pub struct FixedArray<const TSIZE: usize, T: Sized> { /* private fields */ }Expand description
A fixed-capacity array. This type is similar to DynamicArray,
except its capacity is fixed at compile time, and doesn’t change at runtime.
Additionally this type does not require an allocator (the data is inlined inside the struct).
Implementations§
Source§impl<const TSIZE: usize, T: Sized> FixedArray<TSIZE, T>
impl<const TSIZE: usize, T: Sized> FixedArray<TSIZE, T>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new, empty FixedArray.
§Panics
This function will panic if the TSIZE is invalid, i.e.
when either TSIZE is 0 or exceeds [Length::MAX_LENGTH].
Sourcepub const fn length(&self) -> Length
pub const fn length(&self) -> Length
Returns the length of the FixedArray.
pub const fn is_empty(&self) -> bool
Sourcepub const fn capacity(&self) -> Length
pub const fn capacity(&self) -> Length
Returns the capacity of the FixedArray. This is TSIZE
as [Length].
Sourcepub const fn as_slice_const(&self) -> &[T]
pub const fn as_slice_const(&self) -> &[T]
Returns the FixedArray as immutable slice.
Sourcepub const fn as_slice_mut_const(&mut self) -> &mut [T]
pub const fn as_slice_mut_const(&mut self) -> &mut [T]
Returns the FixedArray as mutable slice.
Trait Implementations§
Source§impl<const TSIZE: usize, T: Sized> BorrowMut<[T]> for FixedArray<TSIZE, T>
impl<const TSIZE: usize, T: Sized> BorrowMut<[T]> for FixedArray<TSIZE, T>
Source§fn borrow_mut(&mut self) -> &mut [T]
fn borrow_mut(&mut self) -> &mut [T]
Mutably borrows from an owned value. Read more
Source§impl<const TSIZE: usize, T: Sized> ImmutableArray<T> for FixedArray<TSIZE, T>
impl<const TSIZE: usize, T: Sized> ImmutableArray<T> for FixedArray<TSIZE, T>
Source§impl<const TSIZE: usize, T: Sized> MutableArray<T> for FixedArray<TSIZE, T>
impl<const TSIZE: usize, T: Sized> MutableArray<T> for FixedArray<TSIZE, T>
Source§fn try_push_array<const TARRSIZE: usize>(
&mut self,
arr: [T; TARRSIZE],
) -> Result<(), ArrayError>
fn try_push_array<const TARRSIZE: usize>( &mut self, arr: [T; TARRSIZE], ) -> Result<(), ArrayError>
Pushes raw array to the array. Read more
Source§fn try_push_slice(&mut self, slice: &[T]) -> Result<(), ArrayError>where
T: Clone,
fn try_push_slice(&mut self, slice: &[T]) -> Result<(), ArrayError>where
T: Clone,
Source§fn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>
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]
fn as_slice_mut(&mut self) -> &mut [T]
Represents the array as mutable slice.
Source§fn try_push(&mut self, value: T) -> Result<(), ArrayError>
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])
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,
fn push_slice(&mut self, slice: &[T])where
T: Clone,
Source§impl<const TSIZE: usize, T: Sized + PartialEq, Rhs: AsRef<[T]>> PartialEq<Rhs> for FixedArray<TSIZE, T>
impl<const TSIZE: usize, T: Sized + PartialEq, Rhs: AsRef<[T]>> PartialEq<Rhs> for FixedArray<TSIZE, T>
impl<const TSIZE: usize, T: Sized + Eq> Eq for FixedArray<TSIZE, T>
Auto Trait Implementations§
impl<const TSIZE: usize, T> Freeze for FixedArray<TSIZE, T>where
T: Freeze,
impl<const TSIZE: usize, T> RefUnwindSafe for FixedArray<TSIZE, T>where
T: RefUnwindSafe,
impl<const TSIZE: usize, T> Send for FixedArray<TSIZE, T>where
T: Send,
impl<const TSIZE: usize, T> Sync for FixedArray<TSIZE, T>where
T: Sync,
impl<const TSIZE: usize, T> Unpin for FixedArray<TSIZE, T>where
T: Unpin,
impl<const TSIZE: usize, T> UnsafeUnpin for FixedArray<TSIZE, T>where
T: UnsafeUnpin,
impl<const TSIZE: usize, T> UnwindSafe for FixedArray<TSIZE, T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more