Why Rust?
After years of working with garbage-collected languages, I wanted to understand memory management at a deeper level. Rust's approach to memory safety without a garbage collector is fascinating.
What I've Learned So Far
Ownership
The ownership system is Rust's most unique feature. Every value has a single owner, and when that owner goes out of scope, the value is dropped.
fn main() {
let s1 = String::from("hello");
let s2 = s1; // s1 is moved to s2
// println!("{}", s1); // This would error!
println!("{}", s2); // This works
}
Borrowing & References
You can borrow values without taking ownership:
fn calculate_length(s: &String) -> usize {
s.len()
}
Pattern Matching
Rust's match is incredibly powerful and exhaustive:
match value {
Some(x) => println!("Got: {}", x),
None => println!("Got nothing"),
}
Current Focus
Working through the Rust book's chapters on:
- Error handling with
ResultandOption - Traits and generics
- Lifetimes (the tricky part!)
Next Steps
- Build a small CLI tool
- Explore async Rust with Tokio
- Try WebAssembly with Rust