[][src]Struct nested::Nested

pub struct Nested<T> { /* fields omitted */ }

A two dimensional collection with minimal allocation

T is the owning underlying container.

For instance, it behaves similarly to Vec<Vec<T>> or Vec<String> but only has 2 internal buffers.

It can be used:

  • on your own collection as long as it implements the Collection trait.
  • like a sparse vector
  • when you need to collect (move ownership) many Strings or Vec<T>s

Methods

impl<T: Collection> Nested<T>[src]

pub fn new() -> Self[src]

Create a new Nested.

pub fn with_capacity(len: usize, size: usize) -> Self[src]

Creates a new Nested with given capacity.

len: the expected item count size: the expected total size taken by all items

pub fn push<I: AsRef<Item<T>>>(&mut self, el: I)[src]

Pushes a new item

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

Removes the last element from a Nested and returns it, or None if it is empty.

pub fn extend_empty(&mut self, count: usize)[src]

Extend with count empty elements

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

Returns the number of elements in the Nested.

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

Get the total length taken by the data

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

Returns true if self has a length of zero.

pub fn truncate(&mut self, len: usize)[src]

Shortens the Nested, keeping the first len elements and dropping the rest.

If len is greater than the vector's current length, this has no effect.

Note that this method has no effect on the allocated capacity of the vector.

pub fn clear(&mut self)[src]

Truncates this Nested, removing all contents.

While this means the Nested will have a length of zero, it does not touch its capacity.

pub fn get(&self, index: usize) -> Option<&Item<T>>[src]

Returns a shared reference to the output at this location, if in bounds.

pub fn into_parts(self) -> (Vec<usize>, T)[src]

Converts this Nested into its constituent parts.

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

Returns a reference to the underlying indices.

Each index represents the start of each logical vector beyond the first one.

pub fn data(&self) -> &T[src]

Returns a reference to the underlying data.

The data is stored contiguously.

pub fn iter(&self) -> Iter<T>[src]

Returns an iterator over Nested elements.

pub fn split_off(&mut self, at: usize) -> Nested<T>[src]

Splits the collection into two at the given index.

Returns a newly allocated Self. self contains elements [0, at), and the returned Self contains elements [at, len).

Note that the capacity of self does not change.

Trait Implementations

impl<T: Clone> Clone for Nested<T>[src]

impl<T: Debug> Debug for Nested<T>[src]

impl<T: Eq> Eq for Nested<T>[src]

impl<T: Collection, A: AsRef<Item<T>>> Extend<A> for Nested<T>[src]

impl<T: Collection, A: AsRef<Item<T>>> FromIterator<A> for Nested<T>[src]

impl<T: Hash> Hash for Nested<T>[src]

impl<T: Collection> Index<usize> for Nested<T>[src]

type Output = Item<T>

The returned type after indexing.

impl<T: PartialEq> PartialEq<Nested<T>> for Nested<T>[src]

impl<T> StructuralEq for Nested<T>[src]

impl<T> StructuralPartialEq for Nested<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Nested<T> where
    T: RefUnwindSafe

impl<T> Send for Nested<T> where
    T: Send

impl<T> Sync for Nested<T> where
    T: Sync

impl<T> Unpin for Nested<T> where
    T: Unpin

impl<T> UnwindSafe for Nested<T> where
    T: UnwindSafe

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.