Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Shopping Cart

Build a shopping cart! Create an empty vector, then push 3 items into it: "milk", "bread", and "eggs". First print how many items are in the cart, then list each item.

Expected output:

text
Cart: 3 items
milk
bread
eggs

Hints:

  • Start with let mut cart: Vec<&str> = Vec::new();
  • Use .push() three times to add items
  • Print "Cart: {} items" using .len()
  • Then loop through the cart to print each item
rust
fn main() {
}