Rust Arrays & Vectors Tutorial | Fixed vs Dynamic Collections for Beginners
12views
1likes
08:32
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
🦀 Learn Rust Arrays & Vectors - Essential Collections for Every Rust Programmer!
In this beginner-friendly tutorial, you'll master the difference between fixed-size arrays and dynamic vectors in Rust. We'll write real code in nvim with syntax highlighting and see the output in the terminal.
⏱️ What You'll Learn:
0:00 - Introduction
0:12 - Arrays: Fixed-Size Collections
2:51 - Vectors: Dynamic Collections
5:35 - Iterating Over Collections with For Loops
8:16 - Recap & Next Steps
📚 Topics Covered:
• Creating arrays with let arr = [1, 2, 3, 4, 5]
• Accessing elements with arr[0] (zero-indexed)
• Getting array length with arr.len()
• Creating vectors with Vec::new()
• Adding elements with v.push(item)
• Iterating with for item in collection { }
• Calculating totals and averages
💻 Code Examples:
ARRAYS:
fn main() {
let numbers = [10, 20, 30, 40, 50];
println!("First: {}", numbers[0]);
println!("Length: {}", numbers.len());
}
VECTORS:
fn main() {
let mut fruits = Vec::new();
fruits.push("Apple");
fruits.push("Banana");
println!("Fruits: {:?}", fruits);
}
ITERATION:
fn main() {
let scores = [85, 92, 78, 95, 88];
for score in scores {
println!("Score: {}", score);
}
}
🔑 Key Differences:
• Arrays: Fixed size, known at compile time
• Vectors: Dynamic size, can grow with push()
• Both: Zero-indexed, iterable with for loops
📌 Subscribe for more Rust tutorials!
#Rust #RustLang #Programming #LearnRust #CodingTutorial #Arrays #Vectors #BeginnerProgramming
Back to tutorialsOpen in YouTube
Duration
8:32
Published
December 21, 2025
Added to Codegiz
March 15, 2026