Outline updated November 2026
Rust for C# Programmers
Class Duration
35 hours of live training delivered over 5-10 days to accommodate your scheduling needs.
Student Prerequisites
- Strong working proficiency in modern C# and .NET
- Comfort with the
dotnetCLI, NuGet, and async/await - No prior Rust experience required
Target Audience
C# and .NET engineers adding Rust for fast services, native libraries, CLIs, embedded work, or replacements for unmanaged components. It fits teams that have hit GC pause limits or already tune hot paths with Span<T>. Teams continuing on can move to Memory-Safe Programming with Rust and then Rust Parallel Programming.
Description
This course teaches production Rust to experienced C# developers. Each concept is taught against its C# equivalent, such as ownership against the garbage collector and Result against exceptions. Students compare Rust enums with C# union types and closed hierarchies, and Tokio futures with Task. They also compare traits with interfaces, and procedural macros with source generators. The course ends with an async Rust service covering HTTP, JSON, database access, testing, and CI.
Learning Outcomes
- Write idiomatic Rust using ownership, borrowing, and lifetimes.
- Map common C# idioms to Rust.
- Build CLIs, library crates, and async services on Tokio.
- Use traits and generics where C# uses interfaces and generics.
- Handle errors with
Result<T, E>and?instead of exceptions. - Check AI-generated Rust with the compiler, clippy, and tests.
Training Materials
All students receive comprehensive courseware covering all topics in the course. Courseware is distributed via GitHub in the form of documentation and extensive code samples.
Software Requirements
A free GitHub account, the current stable Rust toolchain via rustup (2024 edition), the .NET 11 SDK for side-by-side C# 15 comparisons, Visual Studio Code or another supported editor with the rust-analyzer extension, and an AI coding assistant of choice (GitHub Copilot, Cursor, or Claude Code). A cloud-based environment can be provided if local installation is restricted.
Training Topics
Introduction: Rust from a C# Perspective
- Where Rust fits next to C#
- What the current edition changed
- Type systems compared
- Runtime, packaging, and performance
- The Rust ecosystem
Toolchain and Editor Setup
- Installing Rust with
rustup cargovs. thedotnetCLI- rust-analyzer in VS Code, RustRover, and Zed
- AI assistants for Rust
- The Rust Playground
Cargo and Crates
cargo new,cargo run,cargo build,cargo testCargo.tomlvs.csprojand NuGet- Workspaces and
cargo publish --workspace - Popular crates such as
serdeandtokio
Rust vs. C#: A Working Map
- Ownership and
Dropvs. GC andIDisposable - Value semantics vs.
structandclass Resultand?vs. exceptionsOption<T>vs. nullable reference types- Structs vs. classes and records
- Rust enums vs. C# unions
- Traits vs. interfaces and extension members
- Monomorphized vs. reified generics
- Iterators vs. LINQ
- Tokio futures vs.
Taskand the TPL
Scalar Types, Control Flow, and Functions
- Integers, floats, booleans, and characters
- Constants, statics, and
const fn if/elseas expressionsloop,while, andforletchains inifandwhile- Closures and capture modes
Modules and the Standard Library
modanduse- Importing from crates.io
- Visibility and re-exports
- A standard library tour for C# developers
Built-In Macros
println!,eprintln!,format!, anddbg!vec!,assert!, andinclude_str!cfg!,env!, andpanic!
Memory Management and Ownership
- Ownership, moves, and copies
- Borrowing with
&Tand&mut T - Slices vs.
Span<T>andMemory<T> - Borrows vs.
ref struct - Lifetimes and the borrow checker
Box,Rc, andArcDropvs.IDisposableand finalizers- Shared object graphs, events, and cycles
Strings, Tuples, Enums, Structs, Collections
Stringvs.&str- UTF-8 vs. UTF-16 strings
- Tuples vs. C# tuples
- Enums with data
Option<T>andResult<T, E>- Inline variants vs. C# case types
- Enum layout vs. boxed union contents
- Default C# unions and null contents
- Structs, methods, and constructors
- Rust collections vs. .NET collections
- Lazy iterators vs. LINQ
Pattern Matching
matchvs. C#switchexpressions- Exhaustiveness over unions and closed hierarchies
if let,while let, andletchains- Destructuring nested data
- Guards, bindings, and
@patterns
Traits and Generics
- Defining and implementing traits
- Default methods and supertraits
- Trait objects with
dyn Trait - Traits on existing types vs. extension members
- Bounds vs. C# generic constraints
- Static vs. dynamic dispatch
- Async fn in traits
Async/Await with Tokio
- Async/await from a
Taskperspective - Lazy futures vs. hot
Tasks - Choosing and configuring a runtime
- Dropping futures vs.
CancellationToken - Async closures
tokio::select!andJoinSet- HTTP with
reqwest - JSON with
serde - Databases with
sqlx
Concurrent Programming
- Threads vs. async tasks
- Compile-time data-race prevention
ArcandMutexvs.lockandInterlocked- Channels vs.
System.Threading.Channels rayonvs.Parallel.ForEachand PLINQ
Unsafe Rust
unsafein Rust vs. C#- Raw pointers and pointer arithmetic
- Safe abstractions over unsafe code
- Auditing
unsafeblocks - Calling Rust from .NET with P/Invoke
Macros and Metaprogramming
- Declarative macros with
macro_rules! - Derive, attribute, and function-like macros
syn,quote, andproc-macro2- Macros vs. source generators
Tests, Documentation, and Quality
- Unit, integration, and doc tests
- Documentation with
rustdoc clippyandrustfmtin CI
AI-Assisted Rust Development for .NET Engineers
- AI tools for Rust work
- Prompts for ownership and trait design
- Catching AI mistakes with the compiler
- Reviewing AI-generated
unsafeandunwrap - Reflexive
Arc<Mutex<T>>in AI code - AI-assisted refactors and code review