Adding elements to vectors
📖 Scenario: You are managing a list of fruits you want to buy from the market. You will start with an empty list and add fruits one by one.
🎯 Goal: Build a Rust program that creates an empty vector of strings, adds fruit names to it, and then prints the final list.
📋 What You'll Learn
Create an empty vector called
fruits to hold String valuesAdd the fruit
"Apple" to the fruits vectorAdd the fruit
"Banana" to the fruits vectorAdd the fruit
"Cherry" to the fruits vectorPrint the
fruits vector to show all fruits added💡 Why This Matters
🌍 Real World
Vectors are used to store lists of items like shopping lists, user inputs, or data records in many programs.
💼 Career
Understanding how to add elements to vectors is essential for managing collections of data efficiently in Rust programming jobs.
Progress0 / 4 steps
