Struct nested::Nested[][src]

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

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

Implementations

Create a new Nested.

Creates a new Nested with given capacity.

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

Pushes a new item

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

Extend with count empty elements

Returns the number of elements in the Nested.

Get the total length taken by the data

Returns true if self has a length of zero.

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.

Truncates this Nested, removing all contents.

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

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

Converts this Nested into its constituent parts.

Returns a reference to the underlying indices.

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

Returns a reference to the underlying data.

The data is stored contiguously.

Returns an iterator over Nested elements.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

Creates a value from an iterator. Read more

Feeds this value into the given Hasher. Read more

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

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.