[][src]Struct pui_vec::PuiVec

pub struct PuiVec<T, I> { /* fields omitted */ }

An append only Vec whitch returns branded indicies that can be used to elide bounds checks.

Implementations

impl<T, I> PuiVec<T, I>[src]

pub const fn new(ident: I) -> Self[src]

Creates a new PuiVec with the given identifier

pub const fn from_raw_parts(vec: Vec<T>, ident: I) -> Self[src]

Creates a new PuiVec with the given identifier and Vec

pub const fn ident(&self) -> &I[src]

Returns a reference to the underlying identifier

pub fn is_empty(&self) -> bool[src]

Returns true if this PuiVec is empty

pub fn len(&self) -> usize[src]

Returns the length of this PuiVec

pub fn capacity(&self) -> usize[src]

Returns the capacity of this PuiVec

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

Reserves capacity for at least additional more elements to be inserted in the given collection. The collection may reserve more space to avoid frequent reallocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.

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

Reserves the minimum capacity for exactly additional more elements to be inserted in the given collection. After calling reserve_exact, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.

Note that the allocator may give the collection more space than it requests. Therefore, capacity can not be relied upon to be precisely minimal. Prefer reserve if future insertions are expected.

pub fn get<A: PuiVecAccess<T, I>>(&self, index: A) -> Option<&A::Output>[src]

Returns a reference to an element or subslice depending on the type of index.

  • If given a position, returns a reference to the element at that position or None if out of bounds.
  • If given a range, returns the subslice corresponding to that range, or None if out of bounds.
  • If given a Id, returns a reference to the element at that position
  • If given a range of Id, returns a the subslice corresponding to that range

pub fn get_mut<A: PuiVecAccess<T, I>>(
    &mut self,
    index: A
) -> Option<&mut A::Output>
[src]

Returns a mutable reference to an element or subslice depending on the type of index. See get for details

pub fn as_mut_parts(&mut self) -> (&I, &mut [T])[src]

Returns a reference to the identifier and a mutable reference to the underlying slice

pub unsafe fn into_raw_parts(self) -> (I, Vec<T>)[src]

Decomposes PuiVec into a it's identifier and it's underling Vec

Safety

The identifier can't be used to create a new PuiVec

impl<T> PuiVec<T, ()>[src]

pub fn vec_mut(&mut self) -> &mut Vec<T>[src]

Get a mutable reference to the underling Vec

impl<T, I> PuiVec<T, I>[src]

pub fn push<Id: BuildPuiVecIndex<I, SliceIndex = usize>>(
    &mut self,
    value: T
) -> Id
[src]

Appends an element to the back of a collection.

Returns an Id or usize

pub fn append(&mut self, vec: &mut Vec<T>)[src]

Moves all the elements of other into Self, leaving other empty.

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

Clones and appends all elements in a slice to the PuiVec.

Iterates over the slice other, clones each element, and then appends it to this Vec. The other vector is traversed in-order.

Note that this function is same as extend except that it is specialized to work with slices instead. If and when Rust gets specialization this function will likely be deprecated (but still available).

impl<T, I: OneShotIdentifier> PuiVec<T, I>[src]

pub fn ids(&self) -> impl ExactSizeIterator<Item = Id<I::Token>> + Clone[src]

Returns an iterator over all the ids in the PuiVec

pub fn parse_id(&self, index: usize) -> Option<Id<I::Token>>[src]

check if the index is in bounds, and if it is, return the corrosponding Id

pub fn swap(&mut self, a: Id<I::Token>, b: Id<I::Token>)[src]

swap two elements, while eliding bounds checks

pub fn split_at(&self, mid: Id<I::Token>) -> (&[T], &[T])[src]

Divides the PuiVec into two slices at an index, while eliding bounds checks.

The first will contain all indices from [0, mid) (excluding the index mid itself) and the second will contain all indices from [mid, len) (excluding the index len itself).

pub fn split_at_mut(&mut self, id: Id<I::Token>) -> (&mut [T], &mut [T])[src]

Divides the PuiVec into two slices at an index, while eliding bounds checks.

The first will contain all indices from [0, mid) (excluding the index mid itself) and the second will contain all indices from [mid, len) (excluding the index len itself).

Trait Implementations

impl<T: Clone, I: Clone> Clone for PuiVec<T, I>[src]

impl<T: Debug, I: Debug> Debug for PuiVec<T, I>[src]

impl<T, I> Deref for PuiVec<T, I>[src]

type Target = [T]

The resulting type after dereferencing.

impl<T, I> DerefMut for PuiVec<T, I>[src]

impl<T: Eq, I: Eq> Eq for PuiVec<T, I>[src]

impl<A, T, I> Extend<A> for PuiVec<T, I> where
    Vec<T>: Extend<A>, 
[src]

impl<T, I, A> Index<A> for PuiVec<T, I> where
    A: PuiVecAccess<T, I>, 
[src]

type Output = A::Output

The returned type after indexing.

impl<T, I, A> IndexMut<A> for PuiVec<T, I> where
    A: PuiVecAccess<T, I>, 
[src]

impl<T, I> IntoIterator for PuiVec<T, I>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

impl<T: Ord, I: Ord> Ord for PuiVec<T, I>[src]

impl<T: PartialEq, I: PartialEq> PartialEq<PuiVec<T, I>> for PuiVec<T, I>[src]

impl<T: PartialOrd, I: PartialOrd> PartialOrd<PuiVec<T, I>> for PuiVec<T, I>[src]

impl<T, I> StructuralEq for PuiVec<T, I>[src]

impl<T, I> StructuralPartialEq for PuiVec<T, I>[src]

Auto Trait Implementations

impl<T, I> Send for PuiVec<T, I> where
    I: Send,
    T: Send
[src]

impl<T, I> Sync for PuiVec<T, I> where
    I: Sync,
    T: Sync
[src]

impl<T, I> Unpin for PuiVec<T, I> where
    I: Unpin,
    T: Unpin
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.