A comprehensive, hands-on learning repository covering Rust programming from fundamentals to advanced topics — including networking, async programming, macros, and system design.
This repository represents a structured learning path through the Rust programming language. Each folder contains working code, experiments, and notes built step-by-step — from basic syntax and ownership to TCP servers, async runtimes, distributed systems, and custom macros.
The goal is not just to learn Rust syntax, but to deeply understand systems programming, memory safety, concurrency, and how Rust's design philosophy solves real-world problems.
.
├── 01_first/ # Rust basics — setup, syntax, types, variables
├── 02_second/ # Control flow, functions, expressions
├── 03_third/ # Ownership, borrowing, and the borrow checker
├── 04_four/ # Structs, enums, pattern matching
├── 05_five/ # Traits, generics, and polymorphism
├── 06_six/ # Error handling — Result, Option, ? operator
├── 07_seven/ # Collections — Vec, HashMap, iterators
├── 08_eight/ # Modules, crates, and project structure (mod, use, pub)
├── 09_nine/ # Closures, higher-order functions, lifetimes
├── 10_ten/ # Smart pointers — Box, Rc, Arc, RefCell
├── 11_eleven/ # Concurrency — threads, channels, shared state
├── Rust_VS_Python/ # Fibonacci calculator — Rust vs Python performance comparison
├── ASYNC_TOKIO/ # Async programming — futures, tokio, reqwest, clap CLI
├── MACRO_TEST/ # Macros — declarative (macro_rules!) and procedural
├── DHT/ # Distributed Hash Table implementation
├── CS/ # Computer Science concepts and algorithms
└── General_README/ # General notes and references
These modules cover the core language features that every Rust programmer must understand.
| Folder | Topic | Key Concepts |
|---|---|---|
01_first |
Basics | Installation, cargo, variables, types,fn main() |
02_second |
Control Flow | if/else, loops,match, functions, expressions |
03_third |
Ownership | Move semantics, borrowing,&and &mut, borrow checker |
04_four |
Data Structures | Structs, enums,Option,Some,None, pattern matching |
05_five |
Traits & Generics | Trait definitions,impl, generics,dyn Trait |
06_six |
Error Handling | Result<T, E>,Option<T>,?operator, custom errors |
07_seven |
Collections | Vec,HashMap, iterators,.map(),.filter(),.collect() |
Building on the foundations with more complex language features.
| Folder | Topic | Key Concepts |
|---|---|---|
08_eight |
Module System | mod,use,pub,crate,super,self,lib.rs |
09_nine |
Closures & Lifetimes | Fn,FnMut,FnOnce, lifetime annotations 'a |
10_ten |
Smart Pointers | Box<T>,Rc<T>,Arc<T>,RefCell<T>, interior mutability |
11_eleven |
Concurrency | std::thread,JoinHandle,Mutex,Arc, channels |
Real-world projects combining everything learned in Phases 1 and 2.
A Fibonacci calculator implemented in both Rust and Python, designed to compare performance and showcase language differences.
-
Iterative approach for efficiency
-
Handles arbitrarily large numbers using
num-bigintcrate (BigUint) -
Solves integer overflow issues that occur with
u128for large inputs (e.g.,fib(500)) -
Execution time measurement using
Instant(Rust) andperf_counter(Python) -
Demonstrates Rust's 5–10x speed advantage over Python for computation
Key Rust Concepts :
-
BigUintfor arbitrary precision integers -
InstantandDurationfor high-precision timing -
Iterative computation with mutable variables
-
Cargo dependency management (
num-bigint)
An async networking project combining multiple advanced topics.
TCP Server (test-tcp-server) :
-
Multi-client async TCP server using
async-std -
Spawns a task per connection (not a thread — lightweight and scalable)
-
Uses
StreamExtfor async iteration over incoming connections -
Demonstrates
TcpListener,TcpStream,write_all,peer_addr -
Non-blocking I/O — thousands of connections on a single thread
Download Manager (
test-tokio) : -
CLI argument parsing with clap (
#[derive(Parser)]) -
HTTP HEAD request with reqwest to check server capabilities
-
Checks
Accept-Ranges: bytesheader for resumable download support -
Custom error types with
enum MyError -
Proper error propagation using
?operator andmap_err -
Supports
--url,--connections, and--fileargumentsKey Rust Concepts :
-
async/awaitsyntax -
futures::join!for concurrent execution -
block_onvs#[tokio::main]for running async code -
Futures, Tasks, Executors, and Reactors
-
Result<T, E>error handling in async context -
async-stdvstokioruntimes
A hands-on exploration of Rust's macro system.
Custom Macro: printlines! :
-
Accepts any number of arguments of any type
-
Prints each value with a label using repetition patterns
-
Defined in
lib.rs, exported with#[macro_export], imported inmain.rsConcepts Covered :
-
macro_rules!syntax and structure -
Fragment specifiers :
expr,ident,ty,stmt,item,pat,tt, and more -
Repetition patterns :
$(...)*(zero or more),$(...)+(one or more),$(...)?(optional) -
Separators in repetition (commas, semicolons)
-
Macro hygiene and scoping
-
#[macro_export]for cross-module macro visibility -
Declarative vs Procedural macros comparison
-
Real-world procedural macro examples:
clap(#[derive(Parser)]),tokio(#[tokio::main])
Fundamental algorithms and data structures implemented in Rust.
Implementation and exploration of Distributed Hash Table concepts — a core building block for peer-to-peer networks, decentralized storage, and distributed systems.
| Category | Tools / Crates |
|---|---|
| Language | Rust (Edition 2021) |
| Build System | Cargo |
| Async Runtime | Tokio, async-std |
| HTTP Client | reqwest |
| CLI Framework | clap |
| Big Integers | num-bigint |
| Async Utilities | futures |
| Networking | std::net, async-std::net |
| Version Control | Git |
- Rust — Install via rustup
- Cargo — Comes with rustup
- Git — For cloning the repo
# Clone the repository
git clone <your-github-repo-url>.git
cd rust-learning-journey
# Navigate to any project folder
cd ASYNC_TOKIO
# Build
cargo build
# Run
cargo run
# Run specific binary (if multiple exist)
cargo run --bin test-tokio -- --url "https://example.com/file"rustc --version
cargo --version- Start with
01_first— Set up your environment and write your first Rust program - Follow the numbered folders in order — Each builds on the previous
- After
11_eleven, move to the project folders (Rust_VS_Python,ASYNC_TOKIO,MACRO_TEST) - Read comments in the code — They explain concepts and reasoning
- Experiment! — Modify the code, break things, and learn from the compiler errors
| # | Topic | Status |
|---|---|---|
| 01 | Basics & Setup | ✅ Done |
| 02 | Control Flow & Functions | ✅ Done |
| 03 | Ownership & Borrowing | ✅ Done |
| 04 | Structs, Enums & Matching | ✅ Done |
| 05 | Traits & Generics | ✅ Done |
| 06 | Error Handling | ✅ Done |
| 07 | Collections & Iterators | ✅ Done |
| 08 | Module System | ✅ Done |
| 09 | Closures & Lifetimes | ✅ Done |
| 10 | Smart Pointers | ✅ Done |
| 11 | Concurrency & Threads | ✅ Done |
| — | Rust vs Python (Fibonacci) | ✅ Done |
| — | Async TCP Server | ✅ Done |
| — | CLI Downloader (clap + reqwest) | ✅ Done |
| — | Macros (Declarative) | ✅ Done |
| — | DHT | 🔄 In Progress |
| — | Computer Science | 🔄 In Progress |
- Move semantics and the ownership model
- Borrowing with
&and&mut - The borrow checker — Rust's compile-time memory safety guarantee
- No garbage collector, no dangling pointers, no data races
- OS threads with
std::thread - Shared state with
Arc<Mutex<T>> - Async concurrency with
async/await - Tasks vs Threads — lightweight vs heavyweight
- Executors and Reactors
- TCP server/client with
std::net(synchronous) - Async TCP with
async-std::net - HTTP requests with
reqwest - Socket programming concepts: bind, listen, accept
- IP addressing:
127.0.0.1,0.0.0.0, ports
- Declarative macros with
macro_rules! - Procedural macros (derive, attribute, function-like)
- Real-world macro usage:
println!,vec!,#[derive(...)],#[tokio::main]
Result<T, E>andOption<T>- The
?operator for error propagation - Custom error types with enums
map_err,unwrap_or,ok_or
| Resource | Link |
|---|---|
| The Rust Book | doc.rust-lang.org/book |
| Rust by Example | doc.rust-lang.org/rust-by-example |
| Rustlings (Exercises) | github.com/rust-lang/rustlings |
| Rust Playground | play.rust-lang.org |
| Async Book | rust-lang.github.io/async-book |
| Crates.io | crates.io |
Rust was chosen for this learning journey because it fundamentally changes how you think about programming:
- Memory Safety without GC — You understand exactly when memory is allocated and freed
- Zero-Cost Abstractions — High-level code compiles to highly optimized machine code
- Fearless Concurrency — The compiler prevents data races at compile time
- Great Tooling —
cargo,rustfmt,clippy, and incredible error messages - Transferable Knowledge — Understanding Rust makes you a better programmer in any language
This project is for educational purposes . Feel free to use, modify, and learn from any of the code here.
Built with dedication and a lot of compiler error messages 🦀