Struct HeaderVec

Source
pub struct HeaderVec<H, T> { /* private fields */ }

Implementations§

Source§

impl<H, T> HeaderVec<H, T>

Source

pub fn capacity(&self) -> usize

The total reserved capacity of the vector.

Source

pub fn as_ptr(&self) -> NonNull<HeaderSlice<H, T>>

Returns a pointer to a HeaderSlice representing this vector.

Source

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.

Source

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.

Source

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.

Source

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

Push a value to the end of the vector.

Source

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

Pop a value from the end of the vec, if there is one.

Source

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.

Source

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.

Source

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()

Source

pub fn with_capacity(head: H, cap: usize) -> Self

Creates an empty HeaderVec with the specified capacity.

Source

pub fn new(head: H) -> Self

Creates an empty HeaderVec.

Source

pub fn truncate(&mut self, new_len: usize)

Shortens the vector to the given length. Panics if new_len > self.len().

Source

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.

Source

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.

Source

pub fn shrink_to_fit(&mut self)

Reallocates so there is no excess capacity (i.e. capacity == length).

Source

pub fn into_box(self) -> Box<HeaderSlice<H, T>>

Converts the vector into a boxed HeaderSlice.

Source

pub fn from_box(src: Box<HeaderSlice<H, T>>) -> Self

Creates a vector from a boxed HeaderSlice.

Source

pub fn reserve(&mut self, additional: usize)

Reserve enough capacity to add at least additional elements without realllocating.

Source

pub fn reserve_exact(&mut self, additional: usize)

Reserve enough capacity to add exactly additional elements without realllocating.

Source

pub fn into_values(self) -> IntoValuesIter<H, T>

Consumes the vector and returns an iterator of its values.

Source

pub fn into_header_values(self) -> (H, IntoValuesIter<H, T>)

Consumes the vector and returns its header and an iterator of its values.

Source

pub fn clear(&mut self)

Delete all items in the vector and reallocate so there is no excess capacity.

Source

pub fn clear_in_place(&mut self)

Delete all items in the vector without reallocating.

Source

pub unsafe fn dealloc_without_dropping(self)

Source

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>>

Source

pub fn new_uninit_values(head: H, len: usize) -> Self

Source

pub unsafe fn assume_init_values(self) -> HeaderVec<H, T>

Source§

impl<H, T> HeaderVec<MaybeUninit<H>, MaybeUninit<T>>

Source

pub unsafe fn assume_init(self) -> HeaderVec<H, T>

Source§

impl<H, T> HeaderVec<MaybeUninit<H>, T>

Source

pub unsafe fn assume_init_head(self) -> HeaderVec<H, T>

Source§

impl<H, T: Copy> HeaderVec<H, T>

Source

pub fn copy_from_slice(head: H, src: &[T]) -> Self

Copies the contents of a slice into a new HeaderVec.

Source

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

Copies the contents onto the end of the vector.

Source§

impl<H, T: Clone> HeaderVec<H, T>

Source

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

Resize the vector. If new_len > self.len(), new entries will be cloned from val.

Source§

impl<H, T: Default> HeaderVec<H, T>

Source

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>

Source

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.

Source

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>>§

Source

pub fn as_truncated(&self, len: usize) -> &Self

Source

pub fn as_truncated_mut(&mut self, len: usize) -> &mut Self

Source

pub unsafe fn resized_unchecked(&mut self, len: usize) -> &mut Self

Source

pub fn len(&self) -> usize

Trait Implementations§

Source§

impl<H, T, I: IntoIterator<Item = T>> Add<I> for HeaderVec<H, T>

Source§

type Output = HeaderVec<H, T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: I) -> Self

Performs the + operation. Read more
Source§

impl<H, T, I: IntoIterator<Item = T>> AddAssign<I> for HeaderVec<H, T>

Source§

fn add_assign(&mut self, rhs: I)

Performs the += operation. Read more
Source§

impl<H, T> AsMut<HeaderSlice<H, T>> for HeaderVec<H, T>

Source§

fn as_mut(&mut self) -> &mut HeaderSlice<H, T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<H, T> AsRef<HeaderSlice<H, T>> for HeaderVec<H, T>

Source§

fn as_ref(&self) -> &HeaderSlice<H, T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<H, T> Borrow<HeaderSlice<H, T>> for HeaderVec<H, T>

Source§

fn borrow(&self) -> &HeaderSlice<H, T>

Immutably borrows from an owned value. Read more
Source§

impl<H, T> BorrowMut<HeaderSlice<H, T>> for HeaderVec<H, T>

Source§

fn borrow_mut(&mut self) -> &mut HeaderSlice<H, T>

Mutably borrows from an owned value. Read more
Source§

impl<H: Clone, T: Clone> Clone for HeaderVec<H, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<H: Debug, T: Debug> Debug for HeaderVec<H, T>

Source§

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

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

impl<H: Default, T> Default for HeaderVec<H, T>

Source§

fn default() -> Self

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

impl<H, T> Deref for HeaderVec<H, T>

Source§

type Target = HeaderSlice<H, T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<H, T> DerefMut for HeaderVec<H, T>

Source§

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

Mutably dereferences the value.
Source§

impl<H, T> Drop for HeaderVec<H, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<H, T> Extend<T> for HeaderVec<H, T>

Source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<H, T> From<Box<HeaderSlice<H, T>>> for HeaderVec<H, T>

Source§

fn from(src: Box<HeaderSlice<H, T>>) -> Self

Converts to this type from the input type.
Source§

impl<H, T> From<HeaderVec<H, T>> for Box<HeaderSlice<H, T>>

Source§

fn from(src: HeaderVec<H, T>) -> Self

Converts to this type from the input type.
Source§

impl<H: Default, T> FromIterator<T> for HeaderVec<H, T>

Source§

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

Creates a value from an iterator. Read more
Source§

impl<H: Hash, T: Hash> Hash for HeaderVec<H, T>

Source§

fn hash<S: Hasher>(&self, state: &mut S)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<H: Ord, T: Ord> Ord for HeaderVec<H, T>

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<H, T, Rhs> PartialEq<Rhs> for HeaderVec<H, T>
where H: PartialEq, T: PartialEq, Rhs: Borrow<HeaderSlice<H, T>> + ?Sized,

Source§

fn eq(&self, rhs: &Rhs) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<H, T, Rhs> PartialOrd<Rhs> for HeaderVec<H, T>
where H: PartialOrd, T: PartialOrd, Rhs: Borrow<HeaderSlice<H, T>> + ?Sized,

Source§

fn partial_cmp(&self, rhs: &Rhs) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<H: Eq, T: Eq> Eq for HeaderVec<H, T>

Auto Trait Implementations§

§

impl<H, T> Freeze for HeaderVec<H, T>

§

impl<H, T> RefUnwindSafe for HeaderVec<H, T>

§

impl<H, T> !Send for HeaderVec<H, T>

§

impl<H, T> !Sync for HeaderVec<H, T>

§

impl<H, T> Unpin for HeaderVec<H, T>

§

impl<H, T> UnwindSafe for HeaderVec<H, T>

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<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.