Welcome to this repository dedicated to learning the Rust programming language. This project is structured as a progressive journey, starting from fundamental concepts to advanced topics like concurrency and memory management.
Each exercise is designed to isolate a specific concept, with detailed explanations and heavily commented source code.
The repository is organized into thematic chapters to facilitate navigation:
- Variables, immutability, and mutability (
let,let mut). - Scalar types (integers, booleans, characters).
- Functions and return values.
- Control flow (
if/else,loop,for).
- Ownership and Move semantics.
- Borrowing with immutable and mutable references.
- Lifetimes and annotations.
- Structures (
struct) and method implementations (impl). - Enumerations (
enum) and Pattern Matching (match). - The
Option<T>enum for handling value absence.
- Dynamic collections: Vectors (
Vec<T>) andHashMap. - Recoverable error handling with
Result<T, E>. - Using
unwrapandexpect.
- Code organization with modules (
mod,pub). - Traits (Interfaces) and Generics.
- Closures and functional iterators.
- Smart Pointers (
Box<T>).
- Multi-threading with
std::thread. - Inter-thread communication via channels (
mpsc). - Writing and executing unit tests.
- Introduction to async with
Tokio(async/.await). - Concurrent task management (
join!,select!,spawn). - Shared state synchronization (
Arc,Mutex). - Async communication channels (
mpsc). - Non-blocking I/O (Files).
- Have Rust installed (including
cargo).
This repository is configured as a Cargo Workspace. You can run any exercise directly from the root without changing directories:
# Example to run exercise 1
cargo run -p exo1
# Example to run exercise 10
cargo run -p exo10To verify your solutions (especially for exercise 28):
# Run tests for a specific package
cargo test -p exo28
# Run all workspace tests
cargo test --workspaceEach exercise has its own README.md describing the learning objectives and key takeaways. The source code is commented to explain the "why" behind each Rust instruction.
Safe travels in the land of memory safety! 🦀