Skip to content

Rust for C#/Java developers — Mission

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#.

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, enum and match instead of class hierarchies;
  • handle errors with Option, Result and ? instead of null and 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.
# 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.