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) -> SelfReturns a new [
AVec<T>] with the provided alignment.fn with_capacity(align: usize, capacity: usize) -> SelfCreates a new empty vector with enough capacity for at least
capacityelements to be inserted in the vector. Ifcapacityis 0, the vector will not allocate.Panics
Panics if the capacity exceeds
isize::MAXbytes.unsafe fn from_raw_parts(ptr: *mut T, align: usize, len: usize, capacity: usize) -> SelfReturns 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) -> usizeReturns the length of the vector.
fn is_empty(&self) -> boolReturns
trueif the vector's length is equal to0, and false otherwise.fn capacity(&self) -> usizeReturns the number of elements the vector can hold without needing to reallocate.
fn reserve(&mut self, additional: usize)Reserves enough capacity for at least
additionalmore elements to be inserted in the vector. After this call toreserve, capacity will be greater than or equal toself.len() + additional. Does nothing if the capacity is already sufficient.Panics
Panics if the new capacity exceeds
isize::MAXbytes.fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>fn reserve_exact(&mut self, additional: usize)Reserves enough capacity for exactly
additionalmore elements to be inserted in the vector. After this call toreserve, capacity will be greater than or equal toself.len() + additional. Does nothing if the capacity is already sufficient.Panics
Panics if the new capacity exceeds
isize::MAXbytes.fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError>fn alignment(&self) -> usizeReturns the alignment of the vector.
fn as_ptr(&self) -> *const TReturns a pointer to the objects held by the vector.
fn as_mut_ptr(&mut self) -> *mut TReturns 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.
Iflenis greater than or equal toself.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
indexwithin the vector, shifting all elements after it to the right.Panics
Panics if
index > len.fn remove(&mut self, index: usize) -> TRemoves and returns the element at position
indexwithin the vector, shifting all elements after it to the left.Panics
Panics if
indexis out of bounds.fn from_iter<I: IntoIterator<Item = T>>(align: usize, iter: I) -> SelfCollects 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
Vecin-place so thatlenis equal tonew_len.If
new_lenis greater thanlen, theVecis extended by the difference, with each additional slot filled withvalue. Ifnew_lenis less thanlen, theVecis 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) -> TReturns the argument unchanged.
impl<T> ToOwned for AVec<T, A>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for AVec<T, A>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses 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>