Module collections::stack
Stack<T> (LIFO)
struct Stack<int> s = std::Stack::new();
s.push(1); s.push(2);
?int top = s.pop(); // 2
s.free();
Backed by one growing heap buffer: O(1) amortized push/pop. peek() hands out a '?&T' into that buffer, valid until the next push()/free().
A Stack owns its elements: it is a Drop type, and T may own something itself (String, Vec, ...). push() takes the element by value (one it can't store is dropped), pop() moves it out, and clear()/drop() drop every element still on the stack.
Structs
| Stack |