[−][src]Struct pinvec::vec::PinVec
Growable vec-like with stable memory addresses.
This structure functions similarly to a typical Vec
.
Whereas a Vec
increases capacity by moving existing
elements to a newer, larger buffer, this collection
is backed by a vector of buffers, each twice as big as
the last, and increases capacity by allocating another
vector for new elements to overflow into, without
invalidating existing elements.
Methods
impl<T> PinVec<T>
[src]
pub fn new(buf_0_len: PowOf2<usize>) -> Self
[src]
New, empty PinVec
.
pub fn len(&self) -> usize
[src]
Current length in elements.
pub fn push(&mut self, elem: T)
[src]
Push an element onto the top of the vector.
Allocates more memory if necessary, but never
moves existing elements do, as that would violate
Pin
invariants.
pub fn remove_top(&mut self) -> bool
[src]
Pop and drop the top element.
Return false if already empty.
Returning element would violate Pin
variants.
pub fn pop(&mut self) -> Option<T> where
T: Unpin,
[src]
T: Unpin,
Pop and return the top element.
Only possible if the element type is Unpin
.
pub unsafe fn pop_unchecked(&mut self) -> Option<T>
[src]
Pop and return the top element, ignoring Pin
invariants.
pub fn set(&mut self, index: usize, elem: T)
[src]
Override an existing element.
Quoting std::pin::Pin:
This overwrites pinned data, but that is okay: its destructor gets run before being overwritten, so no pinning guarantee is violated.
pub fn idx_ref(&self, index: usize) -> Pin<&T>
[src]
Get by index as pinned shared ref, or panic.
pub fn idx_mut(&mut self, index: usize) -> Pin<&mut T>
[src]
Get by index as pinned mutable ref, or panic.
pub fn get_ref(&self, index: usize) -> Option<Pin<&T>>
[src]
Get by index as pinned shared ref.
pub fn get_mut(&mut self, index: usize) -> Option<Pin<&mut T>>
[src]
Get by index as pinned mutable ref.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for PinVec<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for PinVec<T> where
T: Send,
T: Send,
impl<T> Sync for PinVec<T> where
T: Sync,
T: Sync,
impl<T> Unpin for PinVec<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for PinVec<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,