pub struct HeaderVec<H, T> { /* private fields */ }
Implementations§
Source§impl<H, T> HeaderVec<H, T>
impl<H, T> HeaderVec<H, T>
Sourcepub fn as_ptr(&self) -> NonNull<HeaderSlice<H, T>>
pub fn as_ptr(&self) -> NonNull<HeaderSlice<H, T>>
Returns a pointer to a HeaderSlice
representing this vector.
Sourcepub fn as_raw_parts(
&mut self,
) -> (NonNull<Pair<H, MaybeUninit<T>>>, usize, usize)
pub fn as_raw_parts( &mut self, ) -> (NonNull<Pair<H, MaybeUninit<T>>>, usize, usize)
Returns the raw parts (ptr, length, capacity) of the vector without consuming it.
Use at your own risk: it is possible to create multiple instances of the same vector by
passing this to from_raw_parts
. Having multiple instances with the same pointer is “safe”
as long as it is never used mutably (or dropped/consumed) as long as more than one instance
exists.
Sourcepub fn into_raw_parts(self) -> (NonNull<Pair<H, MaybeUninit<T>>>, usize, usize)
pub fn into_raw_parts(self) -> (NonNull<Pair<H, MaybeUninit<T>>>, usize, usize)
Returns the raw parts (ptr, length, capacity) of the vector.
Reconstruct the vector by passing these values to from_raw_parts
.
Sourcepub unsafe fn from_raw_parts(
ptr: NonNull<Pair<H, MaybeUninit<T>>>,
len: usize,
cap: usize,
) -> Self
pub unsafe fn from_raw_parts( ptr: NonNull<Pair<H, MaybeUninit<T>>>, len: usize, cap: usize, ) -> Self
Constructs an instance of this struct using the raw parts returned from as_raw_parts
or
into_raw_parts
.
Sourcepub fn remove(&mut self, index: usize) -> Option<T>
pub fn remove(&mut self, index: usize) -> Option<T>
Removes a value at the given index, if it exiss.
All entries after index
will be shifted to the left.
Sourcepub fn swap_remove(&mut self, index: usize) -> Option<T>
pub fn swap_remove(&mut self, index: usize) -> Option<T>
Remove an element at index
if it exists by replacing it with the last
element of the vector.
Sourcepub fn insert(&mut self, index: usize, val: T)
pub fn insert(&mut self, index: usize, val: T)
Inserts an element at index
, shifting all elements after index
to
the right.
Panics if index > self.len()
Sourcepub fn with_capacity(head: H, cap: usize) -> Self
pub fn with_capacity(head: H, cap: usize) -> Self
Creates an empty HeaderVec
with the specified capacity.
Sourcepub fn truncate(&mut self, new_len: usize)
pub fn truncate(&mut self, new_len: usize)
Shortens the vector to the given length.
Panics if new_len > self.len()
.
Sourcepub fn resize_with(&mut self, new_len: usize, f: impl FnMut() -> T)
pub fn resize_with(&mut self, new_len: usize, f: impl FnMut() -> T)
Resizes the vector.
If new_len > self.len()
, the elements will be instantiated with the
given function.
Sourcepub fn from_iter<I: IntoIterator<Item = T>>(head: H, iter: I) -> Self
pub fn from_iter<I: IntoIterator<Item = T>>(head: H, iter: I) -> Self
Creates a new instance of HeaderVec
from the given header and iterator.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Reallocates so there is no excess capacity (i.e. capacity == length).
Sourcepub fn into_box(self) -> Box<HeaderSlice<H, T>>
pub fn into_box(self) -> Box<HeaderSlice<H, T>>
Converts the vector into a boxed HeaderSlice
.
Sourcepub fn from_box(src: Box<HeaderSlice<H, T>>) -> Self
pub fn from_box(src: Box<HeaderSlice<H, T>>) -> Self
Creates a vector from a boxed HeaderSlice
.
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserve enough capacity to add at least additional
elements without realllocating.
Sourcepub fn reserve_exact(&mut self, additional: usize)
pub fn reserve_exact(&mut self, additional: usize)
Reserve enough capacity to add exactly additional
elements without realllocating.
Sourcepub fn into_values(self) -> IntoValuesIter<H, T> ⓘ
pub fn into_values(self) -> IntoValuesIter<H, T> ⓘ
Consumes the vector and returns an iterator of its values.
Sourcepub fn into_header_values(self) -> (H, IntoValuesIter<H, T>)
pub fn into_header_values(self) -> (H, IntoValuesIter<H, T>)
Consumes the vector and returns its header and an iterator of its values.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Delete all items in the vector and reallocate so there is no excess capacity.
Sourcepub fn clear_in_place(&mut self)
pub fn clear_in_place(&mut self)
Delete all items in the vector without reallocating.
pub unsafe fn dealloc_without_dropping(self)
Sourcepub unsafe fn copy_from_ptr_unsafe(head: H, src: *mut T, len: usize) -> Self
pub unsafe fn copy_from_ptr_unsafe(head: H, src: *mut T, len: usize) -> Self
Copies the contents of a slice into a new HeaderVec
.
Do not use or drop the contents of the original slice after this.
Source§impl<H, T> HeaderVec<H, MaybeUninit<T>>
impl<H, T> HeaderVec<H, MaybeUninit<T>>
pub fn new_uninit_values(head: H, len: usize) -> Self
pub unsafe fn assume_init_values(self) -> HeaderVec<H, T>
Source§impl<H, T> HeaderVec<MaybeUninit<H>, MaybeUninit<T>>
impl<H, T> HeaderVec<MaybeUninit<H>, MaybeUninit<T>>
pub unsafe fn assume_init(self) -> HeaderVec<H, T>
Source§impl<H, T> HeaderVec<MaybeUninit<H>, T>
impl<H, T> HeaderVec<MaybeUninit<H>, T>
pub unsafe fn assume_init_head(self) -> HeaderVec<H, T>
Source§impl<H, T: Copy> HeaderVec<H, T>
impl<H, T: Copy> HeaderVec<H, T>
Sourcepub fn copy_from_slice(head: H, src: &[T]) -> Self
pub fn copy_from_slice(head: H, src: &[T]) -> Self
Copies the contents of a slice into a new HeaderVec
.
Sourcepub fn extend_from_slice(&mut self, src: &[T])
pub fn extend_from_slice(&mut self, src: &[T])
Copies the contents onto the end of the vector.
Source§impl<H, T: Default> HeaderVec<H, T>
impl<H, T: Default> HeaderVec<H, T>
Sourcepub fn resize_default(&mut self, new_len: usize)
pub fn resize_default(&mut self, new_len: usize)
Resize the vector. If new_len > self.len()
, new entries will use the
default value of T
.
Source§impl<H, T: Ord> HeaderVec<H, T>
impl<H, T: Ord> HeaderVec<H, T>
Sourcepub fn insert_sorted(&mut self, val: T)
pub fn insert_sorted(&mut self, val: T)
Assuming the vector is sorted, insert the given value into its sorted position. Behavior is undefined if the vector is not sorted.
Sourcepub fn insert_or_replace_sorted(&mut self, val: T) -> Option<T>
pub fn insert_or_replace_sorted(&mut self, val: T) -> Option<T>
Assuming the vector is sorted, insert the given value into its sorted position
if it does not already exist in the vector.
If an element already exists that compares equal to val
, reaplce it with
val
and return its original value.
Behavior is undefined if the vector is not sorted.
Methods from Deref<Target = HeaderSlice<H, T>>§
pub fn as_truncated(&self, len: usize) -> &Self
pub fn as_truncated_mut(&mut self, len: usize) -> &mut Self
pub unsafe fn resized_unchecked(&mut self, len: usize) -> &mut Self
pub fn len(&self) -> usize
Trait Implementations§
Source§impl<H, T, I: IntoIterator<Item = T>> Add<I> for HeaderVec<H, T>
impl<H, T, I: IntoIterator<Item = T>> Add<I> for HeaderVec<H, T>
Source§impl<H, T, I: IntoIterator<Item = T>> AddAssign<I> for HeaderVec<H, T>
impl<H, T, I: IntoIterator<Item = T>> AddAssign<I> for HeaderVec<H, T>
Source§fn add_assign(&mut self, rhs: I)
fn add_assign(&mut self, rhs: I)
+=
operation. Read moreSource§impl<H, T> AsMut<HeaderSlice<H, T>> for HeaderVec<H, T>
impl<H, T> AsMut<HeaderSlice<H, T>> for HeaderVec<H, T>
Source§fn as_mut(&mut self) -> &mut HeaderSlice<H, T>
fn as_mut(&mut self) -> &mut HeaderSlice<H, T>
Source§impl<H, T> AsRef<HeaderSlice<H, T>> for HeaderVec<H, T>
impl<H, T> AsRef<HeaderSlice<H, T>> for HeaderVec<H, T>
Source§fn as_ref(&self) -> &HeaderSlice<H, T>
fn as_ref(&self) -> &HeaderSlice<H, T>
Source§impl<H, T> Borrow<HeaderSlice<H, T>> for HeaderVec<H, T>
impl<H, T> Borrow<HeaderSlice<H, T>> for HeaderVec<H, T>
Source§fn borrow(&self) -> &HeaderSlice<H, T>
fn borrow(&self) -> &HeaderSlice<H, T>
Source§impl<H, T> BorrowMut<HeaderSlice<H, T>> for HeaderVec<H, T>
impl<H, T> BorrowMut<HeaderSlice<H, T>> for HeaderVec<H, T>
Source§fn borrow_mut(&mut self) -> &mut HeaderSlice<H, T>
fn borrow_mut(&mut self) -> &mut HeaderSlice<H, T>
Source§impl<H, T> Extend<T> for HeaderVec<H, T>
impl<H, T> Extend<T> for HeaderVec<H, T>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)