Skip to main content

ArrayVec

Struct ArrayVec 

Source
pub struct ArrayVec<T, const N: usize> { /* private fields */ }
Expand description

A fixed-capacity vector.

Implementations§

Source§

impl<T, const N: usize> ArrayVec<T, N>

Source

pub const fn new() -> Self

Creates an empty vector.

Source

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

Appends a value, returning an error when the vector is full.

Source

pub fn push(&mut self, value: T)

Appends a value.

§Panics

Panics when the vector is full.

Source

pub fn len(&self) -> usize

Returns the number of stored values.

Source

pub fn is_empty(&self) -> bool

Returns whether the vector is empty.

Source

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

Returns the stored values as a slice.

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns the stored values as a mutable slice.

Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the stored values.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Returns a mutable iterator over the stored values.

Source

pub fn reverse(&mut self)

Reverses the stored values.

Source

pub fn as_ptr(&self) -> *const T

Returns a pointer to the vector’s storage.

Source

pub fn as_mut_ptr(&mut self) -> *mut T

Returns a mutable pointer to the vector’s storage.

Source§

impl<T, const N: usize> ArrayVec<T, N>
where T: Copy + PartialEq,

Source

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

Returns whether the vector contains the given value.

Source§

impl<T, const N: usize> ArrayVec<T, N>
where T: Copy + Ord,

Source

pub fn sort_unstable(&mut self)

Sorts the vector without preserving the order of equal values.

Trait Implementations§

Source§

impl<T: Debug, const N: usize> Debug for ArrayVec<T, N>

Source§

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

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

impl<T, const N: usize> Default for ArrayVec<T, N>

Source§

fn default() -> Self

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

impl<T, const N: usize> Index<usize> for ArrayVec<T, N>
where T: Copy,

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, const N: usize> IndexMut<usize> for ArrayVec<T, N>
where T: Copy,

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, const N: usize> Freeze for ArrayVec<T, N>
where VecInner<T, usize, VecStorageInner<[MaybeUninit<T>; N]>>: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for ArrayVec<T, N>
where VecInner<T, usize, VecStorageInner<[MaybeUninit<T>; N]>>: RefUnwindSafe,

§

impl<T, const N: usize> Send for ArrayVec<T, N>
where VecInner<T, usize, VecStorageInner<[MaybeUninit<T>; N]>>: Send,

§

impl<T, const N: usize> Sync for ArrayVec<T, N>
where VecInner<T, usize, VecStorageInner<[MaybeUninit<T>; N]>>: Sync,

§

impl<T, const N: usize> Unpin for ArrayVec<T, N>
where VecInner<T, usize, VecStorageInner<[MaybeUninit<T>; N]>>: Unpin,

§

impl<T, const N: usize> UnsafeUnpin for ArrayVec<T, N>
where VecInner<T, usize, VecStorageInner<[MaybeUninit<T>; N]>>: UnsafeUnpin,

§

impl<T, const N: usize> UnwindSafe for ArrayVec<T, N>
where VecInner<T, usize, VecStorageInner<[MaybeUninit<T>; N]>>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.