PinnedVec

Struct PinnedVec 

Source
pub struct PinnedVec<T> { /* private fields */ }
Expand description

Vec-like structure whose elements never move.

Implementations§

Source§

impl<T> PinnedVec<T>

Source

pub fn new() -> Self

Create a new, empty PinnedVec. This method does not allocate.

Source

pub fn len(&self) -> usize

Get the length of the PinnedVec (the number of elements inside).

Source

pub fn capacity(&self) -> usize

Get the current capacity of the PinnedVec Pushing within capacity means no extra allocation. Pushing over capacity will cause allocation, increasing capacity.

Source

pub fn get(&self, index: usize) -> Option<Pin<&T>>

Get a pinned reference to the element at the specified index, if it exists.

Source

pub fn get_mut(&mut self, index: usize) -> Option<Pin<&mut T>>

Get a pinned mutable reference to the element at the specified index, if it exists.

Source

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

Push an element to the end of the PinnedVec. Might cause the PinnedVec to allocate a new sub-vector.

Source

pub fn pop(&mut self)

Remove the last element in the PinnedVec. The element is not returned because that would violate Pin invariant.

§Panics

Panics if the vec is empty.

Source

pub fn replace(&mut self, index: usize, item: T)

Replace the element at the specified index with another one. The element is not returned because that would violate Pin invariant.

§Panics

Panics if index is not in the vec (i.e. len >= index).

Auto Trait Implementations§

§

impl<T> Freeze for PinnedVec<T>

§

impl<T> RefUnwindSafe for PinnedVec<T>
where T: RefUnwindSafe,

§

impl<T> Send for PinnedVec<T>
where T: Send,

§

impl<T> Sync for PinnedVec<T>
where T: Sync,

§

impl<T> Unpin for PinnedVec<T>
where T: Unpin,

§

impl<T> UnwindSafe for PinnedVec<T>
where T: 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<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, 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.