Rust for TypeScript & C# developers
Learn Rust with the language you already know.
Every lesson puts your language next to the Rust that does the same job, then explains what changes: who owns memory, what the compiler checks, and why. Every example on this site is compiled and run before it's published.
Side by side
No null in Rust: a value that might be missing is an Option, and the compiler makes you handle both cases.
function findUser(id: number): string | undefined {
return id === 1 ? "Ada" : undefined;
}
const user = findUser(2);
console.log(user ?? "nobody");var user = FindUser(2);
Console.WriteLine(user ?? "nobody");
static string? FindUser(int id) => id == 1 ? "Ada" : null;fn find_user(id: u32) -> Option<&'static str> {
if id == 1 { Some("Ada") } else { None }
}
fn main() {
let user = find_user(2);
println!("{}", user.unwrap_or("nobody"));
}Output
nobody
How each lesson works
- Concept map
A table of each idea in your language and in Rust, to scan before reading.
- Side-by-side code
The same small program in your language and in Rust, with the same names.
- Which one to use
What each option is, when to use it, why, and how.
- Under the hood
Memory diagrams and real compiler errors, explained.
- Common pitfalls
The traps TypeScript and C# developers hit first.
- Try it
Port a short program to Rust, with a hint and a checked solution.
Curriculum
Module 0 Orientation & tooling
Why Rust works without a garbage collector, and the tools you'll use every day: rustup, Cargo, clippy and rustfmt.
Module 1 Fundamentals
Variables, mutability, shadowing, number types and functions, why almost everything in Rust is an expression, and what Rust's punctuation means.
Module 2 Ownership & memory
Where values live, who frees them, and why assigning a String moves it instead of sharing it.
- 2.1Stack vs. heapDone
- 2.2Ownership and move semanticsDone
- 2.3Copy vs. CloneDone
Module 3 Borrowing & slices
Lending values without giving them away: shared and mutable references, zero-copy slices, and how to choose what a function takes.
Module 4 Control flow & pattern matching
if and loop as expressions, exhaustive match, and the short forms: if let, while let and let-else.
Module 5 Structs, methods & enums
Data and behavior without classes or inheritance, and enums that carry data.
- 5.1Structs & impl blocksDone
- 5.2Enums with dataDone
Module 6 Nullability & error handling
Option instead of null, Result instead of exceptions, and the ? operator.
Module 7 Modules & crates
Organizing code with modules and visibility, and projects with crates, workspaces and features.
- 7.1Modules, visibility & pathsDone
- 7.2Crates, workspaces & featuresDone
Module 8 Collections & strings
Vec, HashMap and friends, and why Rust strings are UTF-8 and can't be indexed by position.
- 8.1Vec, HashMap, HashSet & BTreeMapDone
- 8.2Strings: UTF-8 vs UTF-16Done
Module 9 Traits & generics
Rust's answer to interfaces, generic bounds, static vs. dynamic dispatch, and the standard traits.
- 9.1TraitsDone
- 9.2Generics, bounds & whereDone
- 9.3impl Trait vs. dyn TraitDone
- 9.4Standard traitsDone
Module 10 Closures & iterators
Closures and what they capture, and lazy iterator chains that compile to plain loops.
- 10.1Closures & Fn, FnMut, FnOnceDone
- 10.2Lazy iteratorsDone
Module 11 Lifetimes & smart pointers
How long references are valid, deterministic cleanup with Drop, and shared ownership when you need it.
- 11.1LifetimesDone
- 11.2Drop & smart pointersDone
- 11.3Shared ownership & interior mutabilityDone
Module 12 Concurrency & async
Threads and channels, compile-time thread safety with Send and Sync, and async Rust with Tokio.
- 12.1Threads, channels & shared stateDone
- 12.2Send & SyncDone
- 12.3Async, futures & TokioDone
Module 13 Testing, macros & unsafe
Built-in tests and doc tests, macros and serde, what unsafe Rust is for, and running Rust in the browser with WebAssembly.
- 13.1Tests & doc testsDone
- 13.2Macros & serdeDone
- 13.3unsafe & FFIDone
- 13.4Rust & WebAssemblyDone