0
0
Rustprogramming~15 mins

Why Rust is used - See It in Action

Choose your learning style9 modes available
Why Rust is Used
๐Ÿ“– Scenario: Imagine you are a software developer who wants to build a fast and safe program. You have heard about Rust, a programming language that helps you do this well.
๐ŸŽฏ Goal: You will create a simple Rust program that shows why Rust is used by printing key reasons. This will help you understand Rust's benefits in a clear way.
๐Ÿ“‹ What You'll Learn
Create a list of reasons why Rust is used
Add a variable to count the number of reasons
Use a loop to print each reason with its number
Print the total number of reasons at the end
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Rust is used in real-world projects where safety and speed are important, like web browsers, game engines, and operating systems.
๐Ÿ’ผ Career
Knowing why Rust is used helps you explain its benefits in job interviews and understand when to choose Rust for software development.
Progress0 / 4 steps
1
Create a list of reasons why Rust is used
Create a variable called reasons that is a vector containing these exact strings: "Memory safety without garbage collection", "Fast performance", "Concurrency without data races", "Great tooling and compiler errors".
Rust
Need a hint?

Use let reasons = vec!["string1", "string2", ...]; to create the list.

2
Add a variable to count the number of reasons
Add a variable called count that stores the length of the reasons vector using reasons.len().
Rust
Need a hint?

Use let count = reasons.len(); to get the number of items.

3
Use a loop to print each reason with its number
Use a for loop with variables i and reason to iterate over reasons.iter().enumerate(). Inside the loop, print each reason with its number starting from 1 using println!("{}. {}", i + 1, reason);.
Rust
Need a hint?

Use for (i, reason) in reasons.iter().enumerate() { ... } and print with println!("{}. {}", i + 1, reason);.

4
Print the total number of reasons at the end
After the loop, print the total number of reasons using println!("Total reasons: {}", count);.
Rust
Need a hint?

Use println!("Total reasons: {}", count); to show the total.