1pub fn stack_0() {
3 let mut v = vec![11, 22, 33, 44];
4 println!("Original: {v:?}");
5 let pop = v.pop().expect("There was none left");
6 println!("Popped {pop} which leaves {v:?}");
7 let push = 55;
8 v.push(push);
9 println!("Pushed {push} which leaves {v:?}");
10 let last = v.last();
11 println!(
12 "The last (top) element is {} which still leaves {:?}",
13 last.expect("Aint nothin there"),
14 v
15 );
16 println!("The size of the stack is {}", v.len());
17 if v.is_empty() {
18 println!("Its empty :(")
19 } else {
20 println!("Theres still {} elements in the stack!", v.len())
21 }
22}