Rust for C#/Java developers — Mission
Why I’m learning this
Section titled “Why I’m learning this”I write C# (and read plenty of Java), and a growing part of my ecosystem — IX, hari — is written in Rust. I want to read and change that code with confidence instead of guessing, and understand why the compiler rejects what would be perfectly fine in C#.
Who this course is for
Section titled “Who this course is for”You are comfortable with C# or Java: classes, interfaces, generics, exceptions, collections, LINQ or Streams, async/await or CompletableFuture.
You have never written Rust. Each lesson starts from the concept you already know and shows where Rust agrees, where it differs, and why.
By the end of this course, I will be able to
Section titled “By the end of this course, I will be able to”- set up a Rust project with Cargo and navigate the tooling;
- explain ownership, borrowing and lifetimes in terms of what a garbage collector normally does for me;
- model data with
struct,enumandmatchinstead of class hierarchies; - handle errors with
Option,Resultand?instead ofnulland exceptions; - use traits, generics and iterators the way I use interfaces, generics and LINQ/Streams;
- write safe concurrent and async code;
- test, document and lint a crate.
Outline
Section titled “Outline”| # | Lesson | You already know |
|---|---|---|
| 1 | Toolchain and Cargo | dotnet CLI, NuGet, Maven/Gradle |
| 2 | Types, mutability and expressions | var, final/readonly, int/long, ternaries |
| 3 | Ownership and moves | the garbage collector, IDisposable, try-with-resources |
| 4 | Borrowing and strings | references, string/String, StringBuilder |
| 5 | Structs, enums and pattern matching | classes, records, sealed hierarchies, switch |
| 6 | Option, Result and ? |
null, exceptions |
| 7 | Traits and generics | interfaces, generics |
| 8 | Collections and iterators | LINQ, Streams |
| 9 | Lifetimes | — |
| 10 | Modules, crates and workspaces | namespaces/packages, projects, solutions |
| 11 | Box, Rc, Arc, RefCell |
references, shared objects |
| 12 | Threads, Send/Sync, Mutex, rayon |
Thread, lock/synchronized, Parallel.For |
| 13 | async and tokio |
async/await, CompletableFuture |
| 14 | Tests, docs, clippy, fmt | xUnit/JUnit, XML docs/Javadoc, analyzers |
| 15 | Macros, unsafe and FFI (overview) |
source generators, P/Invoke, JNI |
A follow-up course, Rust in practice: IX and co, applies each of these ideas to real code in IX, hari and my other Rust repositories.
Journal — what I tried, what surprised me, what I still need to verify.
Resources
Section titled “Resources”- The Rust Programming Language (“the Book”) — the official, free introduction.
- Rust by Example — short runnable examples.
- The Cargo Book — build tool and package manager.
- Rust standard library docs.
- Rust Error Codes Index — every
E0xxxexplained, also available offline withrustc --explain E0382.