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 C# and .NET (.NET 8+ familiarity recommended)
- Comfort with
dotnetCLI, NuGet, and async/await - No prior Rust experience required
Target Audience
C# and .NET engineers adding Rust to their toolkit — for performance-critical services, native libraries, CLIs, embedded work, or memory-safe replacements for legacy unmanaged components. Particularly relevant for teams that have hit GC pause limits, run hot paths through Span<T>/Memory<T>, or want a compiled-language story without a runtime.
Description
This course gives experienced C# developers a structured pathway to production Rust on the 2024 edition (Rust 1.85 introduced the edition; 1.95+ recommended for the current toolchain). Every concept is introduced in contrast with the C#/.NET equivalent: ownership and borrowing vs. the GC, traits vs. interfaces, structs and enums vs. records and discriminated unions (and how Rust enums actually deliver on the latter), async/await on Tokio vs. Task, monomorphized generics vs. .NET generics. The course closes with a real, end-to-end Rust service — built with AI assistance from Claude Code, Cursor, or GitHub Copilot — that participants can reason about as confidently as their C# code.
Learning Outcomes
- Read and write idiomatic Rust on the 2024 edition with confidence in ownership, borrowing, and lifetimes.
- Translate C# idioms to Rust and vice versa, knowing where each language is the right tool.
- Build CLIs, library crates, and async services on Tokio.
- Apply traits and generics where C# developers reach for interfaces and .NET generics.
- Write idiomatic error handling with
Result<T, E>and the?operator instead of exceptions. - Use AI coding assistants effectively for Rust while letting the compiler, clippy, and tests catch what AI gets wrong.
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. Students practice the topics covered through challenging hands-on lab exercises, including a capstone async service that exercises traits, async, and idiomatic error handling.
Software Requirements
A free GitHub account, the latest stable Rust toolchain installed via rustup (Rust 1.95+ on the 2024 edition), 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
- What Rust is and where it fits relative to C#/.NET
- Rust 2024 edition: what's new and why it matters
- Rust vs. C#: type system, runtime, packaging, performance
- The Rust ecosystem and community
Toolchain and Editor Setup
- Installing Rust with
rustup cargovs.dotnetCLI: similarities and differences- VS Code, JetBrains RustRover, and Zed with rust-analyzer
- AI assistants for Rust: Copilot, Cursor, and Claude Code
- The Rust Playground for quick experimentation
Cargo and Crates
cargo new,cargo run,cargo build,cargo testCargo.tomland dependencies vs.csprojand NuGet- Workspaces and
cargo publish --workspace - Popular crates:
serde,tokio,reqwest,sqlx,anyhow,thiserror,tracing
Rust vs. C#: A Working Map
- Memory management: ownership vs. GC
- Errors:
Result/Optionvs. exceptions - Sequence, selection, and iteration
- Structs vs. classes and records
- Enums with associated data vs. records and unions
- Traits vs. interfaces (and what neither has)
- Generics: monomorphization vs. .NET generics
- Concurrency: Tokio + async/await vs.
Taskand TPL
Scalar Types, Control Flow, and Functions
- Integers, floats, booleans, characters
- Constants, statics, and
const fn if/elseas expressions,loop,while,for- 2024-edition
let-chains inifandwhile - Functions, closures, and capture modes
Modules and the Standard Library
- Module hierarchy with
modanduse - Importing from the standard library and crates.io
- Visibility and re-exports
- A short tour of the standard library a C# developer will recognize
Built-In Macros
print!,println!,eprintln!,format!,dbg!vec!,assert!,include_str!,include_bytes!cfg!,env!,panic!
Memory Management and Ownership
- Ownership, moves, and copies
- Borrowing:
&Tand&mut T - Lifetimes and the borrow checker
Box,Rc,Arc, and when each is appropriate- Drop and the
Droptrait - Common C# developer pitfalls
Strings, Tuples, Enums, Structs, Collections
Stringvs.&str- Tuples and tuple structs
- Enums with associated data,
Option<T>,Result<T, E> - Structs, methods, associated functions, constructors
Vec,HashMap,HashSet,BTreeMap/BTreeSet- Iterators and combinators (
map,filter,fold,try_fold)
Pattern Matching
matchand exhaustivenessif let,while let, and 2024let-chains- Destructuring nested data
- Guards, bindings, and
@patterns
Traits and Generics
- Defining and implementing traits
- Default methods, supertraits, and trait objects (
dyn Trait) - Generics, bounds, and
whereclauses - Static dispatch (monomorphization) vs. dynamic dispatch
- Async fn in traits
Async/Await with Tokio
- The async/await mental model from a C#
Taskperspective - Tokio runtime fundamentals
- 2024-edition async closures
tokio::select!,JoinSet, structured cancellation- HTTP with
reqwest, JSON withserde, databases withsqlx
Concurrent Programming
- Threads vs. async tasks
Send,Sync, and the data-race storyArc,Mutex,RwLock, channels- A short tour of
rayonfor data parallelism
Unsafe Rust
- The
unsafesuperpowers and what they mean - Raw pointers, dereferencing, and pointer arithmetic
- Calling unsafe functions and writing safe abstractions
- Auditing
unsafeblocks
Macros and Metaprogramming
- Declarative macros with
macro_rules! - Procedural macros: derive, attribute, and function-like
- Working with
syn,quote, andproc-macro2at a glance - Comparison with Roslyn source generators
Tests, Documentation, and Quality
- Unit tests, integration tests, and doctests
rustdocand writing documentation that compilesclippyandrustfmtin CI
AI-Assisted Rust Development for .NET Engineers
- The 2026 AI-coding-tool landscape and how .NET developers use it for Rust
- Prompts that work well for Rust ownership, lifetimes, and trait design
- Letting the compiler, clippy, and tests catch what AI gets wrong
- Reviewing AI-generated
unsafe,unwrap, and reflexiveArc<Mutex<T>> - Agentic Rust workflows: AI-assisted refactors, code review, and CI
Capstone
- Build a small async Rust service with idiomatic error handling, traits, and tests — written with AI assistance and validated by the compiler, clippy, and a benchmark
- Course wrap-up and recommended next courses