23.17 Stacks

Stacks

Overview

A Stack is a LIFO (Last In, First Out) data structure where elements are added and removed from the top.

Topics

Examples

let mut stack = Vec::new();
stack.push(1);
stack.push(2);
stack.push(3);

println!("Popped: {}", stack.pop().unwrap());
println!("Top: {}", stack.last().unwrap());

Tags

#rust #stack