pub struct StackA<T: ?Sized, D: DataBuf> { /* private fields */ }
Expand description

A fixed-capacity stack that can contain dynamically-sized types

Uses an array of usize as a backing store for a First-In, Last-Out stack of items that can unsize to T.

Note: Each item in the stack takes at least one slot in the buffer (to store the metadata)

Implementations

Construct a new (empty) stack

Construct a new (empty) stack using the provided buffer

Tests if the stack is empty

Push a value at the top of the stack

Push a value at the top of the stack (without using Unsize)

Returns a pointer to the top item on the stack

Returns a pointer to the top item on the stack (unique/mutable)

Pop the top item off the stack

Obtain an immutable iterator (yields references to items, in the order they would be popped)

let mut list = ::stack_dst::StackA::<str, [usize; 8]>::new();
list.push_str("Hello");
list.push_str("world");
let mut it = list.iter();
assert_eq!(it.next(), Some("world"));
assert_eq!(it.next(), Some("Hello"));
assert_eq!(it.next(), None);

Obtain unique/mutable iterator

let mut list = ::stack_dst::StackA::<[u8], [usize; 8]>::new();
list.push_copied(&[1,2,3]);
list.push_copied(&[9]);
for v in list.iter_mut() {
    v[0] -= 1;
}
let mut it = list.iter();
assert_eq!(it.next(), Some(&[8][..]));
assert_eq!(it.next(), Some(&[0,2,3][..]));
assert_eq!(it.next(), None);

Push the contents of a string slice as an item onto the stack

Pushes a set of items (cloning out of the input slice)

Pushes a set of items (copying out of the input slice)

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Executes the destructor for this type. 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.

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.