Struct AVec

pub struct AVec<T, A: Alignment = ConstAlign<CACHELINE_ALIGN>> { /* private fields */ }

Aligned vector. See Vec for more info.

Note: passing an alignment value of 0 or a power of two that is less than the minimum alignment will cause the vector to use the minimum valid alignment for the type T and alignment type A.

Implementations

impl<T, A: Alignment> AVec<T, A>

fn new(align: usize) -> Self

Returns a new [AVec<T>] with the provided alignment.

fn with_capacity(align: usize, capacity: usize) -> Self

Creates a new empty vector with enough capacity for at least capacity elements to be inserted in the vector. If capacity is 0, the vector will not allocate.

Panics

Panics if the capacity exceeds isize::MAX bytes.

unsafe fn from_raw_parts(ptr: *mut T, align: usize, len: usize, capacity: usize) -> Self

Returns a new [AVec<T>] from its raw parts.

Safety

The arguments to this function must be acquired from a previous call to Self::into_raw_parts.

fn into_raw_parts(self) -> (*mut T, usize, usize, usize)

Decomposes an [AVec<T>] into its raw parts: (ptr, alignment, length, capacity).

fn len(&self) -> usize

Returns the length of the vector.

fn is_empty(&self) -> bool

Returns true if the vector's length is equal to 0, and false otherwise.

fn capacity(&self) -> usize

Returns the number of elements the vector can hold without needing to reallocate.

fn reserve(&mut self, additional: usize)

Reserves enough capacity for at least additional more elements to be inserted in the vector. After this call to reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.

Panics

Panics if the new capacity exceeds isize::MAX bytes.

fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
fn reserve_exact(&mut self, additional: usize)

Reserves enough capacity for exactly additional more elements to be inserted in the vector. After this call to reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.

Panics

Panics if the new capacity exceeds isize::MAX bytes.

fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError>
fn alignment(&self) -> usize

Returns the alignment of the vector.

fn as_ptr(&self) -> *const T

Returns a pointer to the objects held by the vector.

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

Returns a mutable pointer to the objects held by the vector.

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

Returns a reference to a slice over the objects held by the vector.

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

Returns a mutable reference to a slice over the objects held by the vector.

fn push(&mut self, value: T)

Push the given value to the end of the vector, reallocating if needed.

fn pop(&mut self) -> Option<T>

Remove the last value from the vector if it exists, otherwise returns None.

fn shrink_to(&mut self, min_capacity: usize)

Shrinks the capacity of the vector with a lower bound.
The capacity will remain at least as large as both the length and the supplied value.
If the current capacity is less than the lower limit, this is a no-op.

fn shrink_to_fit(&mut self)

Shrinks the capacity of the vector as much as possible without dropping any elements.

fn truncate(&mut self, len: usize)

Drops the last elements of the vector until its length is equal to len.
If len is greater than or equal to self.len(), this is a no-op.

fn clear(&mut self)

Drops the all the elements of the vector, setting its length to 0.

fn into_boxed_slice(self) -> ABox<[T], A>

Converts the vector into [ABox<T>].
This will drop any excess capacity.

fn insert(&mut self, index: usize, element: T)

Inserts an element at position index within the vector, shifting all elements after it to the right.

Panics

Panics if index > len.

fn remove(&mut self, index: usize) -> T

Removes and returns the element at position index within the vector, shifting all elements after it to the left.

Panics

Panics if index is out of bounds.

fn from_iter<I: IntoIterator<Item = T>>(align: usize, iter: I) -> Self

Collects an iterator into an [AVec<T>] with the provided alignment.

fn from_slice(align: usize, slice: &[T]) -> Self
where
    T: Clone,

Collects a slice into an [AVec<T>] with the provided alignment.

unsafe fn set_len(&mut self, new_len: usize)
fn append<OtherA: Alignment>(&mut self, other: &mut AVec<T, OtherA>)

impl<T: Clone, A: Alignment> AVec<T, A>

fn resize(&mut self, new_len: usize, value: T)

Resizes the Vec in-place so that len is equal to new_len.

If new_len is greater than len, the Vec is extended by the difference, with each additional slot filled with value. If new_len is less than len, the Vec is simply truncated.

fn extend_from_slice(&mut self, other: &[T])

Clones and appends all elements in a slice to the Vec.

Trait Implementations

impl<T, A: Alignment> AsMut<[T]> for AVec<T, A>

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

impl<T, A: Alignment> AsRef<[T]> for AVec<T, A>

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

impl<T, A: Alignment> Deref for AVec<T, A>

type Target = [T];
fn deref(&self) -> &Self::Target

impl<T, A: Alignment> DerefMut for AVec<T, A>

fn deref_mut(&mut self) -> &mut Self::Target

impl<T, A: Alignment> Drop for AVec<T, A>

fn drop(&mut self)

impl<T, A: Alignment> From<ABox<[T], A>> for AVec<T, A>

fn from(value: ABox<[T], A>) -> Self

impl<T: Clone, A: Alignment> Clone for AVec<T, A>

fn clone(&self) -> Self

impl<T: Debug, A: Alignment> Debug for AVec<T, A>

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

impl<T: Eq, A: Alignment> Eq for AVec<T, A>

impl<T: Ord, A: Alignment> Ord for AVec<T, A>

fn cmp(&self, other: &Self) -> Ordering

impl<T: PartialEq, A: Alignment> PartialEq for AVec<T, A>

fn eq(&self, other: &Self) -> bool

impl<T: PartialOrd, A: Alignment> PartialOrd for AVec<T, A>

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

impl<T: Send, A: Alignment + Send> Send for AVec<T, A>

impl<T: Sync, A: Alignment + Sync> Sync for AVec<T, A>

Auto Trait Implementations

impl<T, A> Freeze for AVec<T, A> where ARawVec<T, A>: Freeze,

impl<T, A> RefUnwindSafe for AVec<T, A> where ARawVec<T, A>: RefUnwindSafe,

impl<T, A> Unpin for AVec<T, A> where ARawVec<T, A>: Unpin,

impl<T, A> UnsafeUnpin for AVec<T, A> where ARawVec<T, A>: UnsafeUnpin,

impl<T, A> UnwindSafe for AVec<T, A> where ARawVec<T, A>: UnwindSafe,

Blanket Implementations

impl<P, T> Receiver for AVec<T, A> where P: Deref<Target = T> + ?Sized, T: ?Sized,

type Target = T;

impl<T> Any for AVec<T, A> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for AVec<T, A> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for AVec<T, A> where T: ?Sized,

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

impl<T> CloneToUninit for AVec<T, A> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for AVec<T, A>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for AVec<T, A> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for AVec<T, A> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for AVec<T, A> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>