pub struct ArrayStack<T> {
    pub mode: ExpansionMode,
    /* private fields */
}
Expand description

A fixed-size stack capable of expanding when needed. It is implemented using Vec, so the elements are stored contiguously in memory. The main difference between this and a Stack is that this one does not use nodes.

Depending on the expansion mode, once the capacity is reached, the deque will behave differently depending on the mode. For more information, see the ExpansionMode documentation.

Examples

use trait_based_collection::{prelude::*, ArrayStack};

let mut stack = ArrayStack::with_mode(2, ExpansionMode::Ignore);
stack.add(1);
stack.add(2);
stack.add(3);

assert_eq!(stack.len(), 2);
assert_eq!(stack.remove(), Some(2));
assert_eq!(stack.remove(), Some(1));
assert_eq!(stack.remove(), None);

Fields

mode: ExpansionMode

The current mode of expansion of the deque that determinate the behaviour the collection is full. See ExpansionMode for more information.

Trait Implementations

Creates a new Collection with a default capacity. Read more
Creates a new Collection with a specific capacity. Read more
Creates a new Collection with a capacity that is at least the specified capacity. Read more
Adds an item to the Collection. Read more
Removes an item from the Collection. Read more
Clears all items from the Collection while keeping the capacity. Read more
Returns an immutable reference of the item that will be removed next. Read more
Returns a mutable reference of the item that will be removed next. Read more
Returns the number of items in the Collection. Read more
Returns a immutable reference to the n-th item in the Collection. Read more
Returns a mutable reference to the n-th item in the Collection. Read more
Checks if the Collection is empty. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
Executes the destructor for this type. 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 new fixed size Collection with the specified capacity and ExpansionMode. Read more
Returns the maximum amount of items that the collection can hold without expanding. Read more
Expands the capacity of the collection by at least the specified amount. This amount or more will be dded to the capacity. Read more
Returns the ExpansionMode of the collection . This is used to determine how the collection will behave when it is full. Read more
Checks if the number of items in the FixedSizeCollection is equal to the capacity. Read more
Creates a value from an iterator. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of reference the immutable iterator (Iter) iterates over the items in the Collection. The reference is only valid for the duration of the iteration. Read more
The type of mutable reference the mutable iterator (IterMut) iterates over the items in the Collection. The reference is only valid for the duration of the iteration. Read more
Which kind of iterator is returned by iter. Read more
Which kind of iterator is returned by iter_mut. Read more
Creates an immutable iterator over the items in the Collection without consuming them. Read more
Creates a mutable iterator over the items in the Collection without consuming them. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. 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.