Struct vector_array::vec::VecArray
source · pub struct VecArray<T, const CAP: usize> { /* private fields */ }
Expand description
A Vec but entirely on the stack.
Example:
use vector_array::vec::VecArray;
let mut vec: VecArray<_, 10> = VecArray::new();
vec.push(9).unwrap();
assert_eq!(vec[0], 9);
Implementations§
source§impl<T, const CAP: usize> VecArray<T, CAP>where
T: Default,
impl<T, const CAP: usize> VecArray<T, CAP>where T: Default,
sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Initializes all elements with defaults (does not increment length, so is pretty useless)
Example:
use vector_array::vec::VecArray;
let mut vec: VecArray<_, 10> = VecArray::new_default();
vec.push(9).unwrap();
assert_eq!(vec[0], 9);
source§impl<T, const CAP: usize> VecArray<T, CAP>
impl<T, const CAP: usize> VecArray<T, CAP>
pub fn new_arr(arr: [T; CAP], len: usize) -> Self
sourcepub fn push(&mut self, value: T) -> Result<(), ArrTooSmall>
pub fn push(&mut self, value: T) -> Result<(), ArrTooSmall>
Pushes an element.
Example:
use vector_array::vec::VecArray;
let mut vec: VecArray<_, 10> = VecArray::new();
vec.push(9).unwrap();
assert_eq!(vec[0], 9);
pub fn get(&self, index: usize) -> Option<&T>
pub fn set(&mut self, index: usize, value: T) -> Result<(), ArrTooSmall>
pub fn truncate(&mut self, len: usize)
pub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_ptr(&self) -> *const T
pub fn get_arr(self) -> [T; CAP]
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_slice(&self) -> &[T]
pub fn as_mut_slice(&mut self) -> &mut [T]
pub fn clear(&mut self)
pub fn capacity(&self) -> usize
Trait Implementations§
source§impl<T, const CAP: usize> IntoIterator for VecArray<T, CAP>
impl<T, const CAP: usize> IntoIterator for VecArray<T, CAP>
Auto Trait Implementations§
impl<T, const CAP: usize> RefUnwindSafe for VecArray<T, CAP>where T: RefUnwindSafe,
impl<T, const CAP: usize> Send for VecArray<T, CAP>where T: Send,
impl<T, const CAP: usize> Sync for VecArray<T, CAP>where T: Sync,
impl<T, const CAP: usize> Unpin for VecArray<T, CAP>where T: Unpin,
impl<T, const CAP: usize> UnwindSafe for VecArray<T, CAP>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