Reference · look it up

The C# thing → the Rust thing.

A flat index of the mappings spread across the chapters. Find the C# construct you know in the left column; the right column is its Rust counterpart, and the last column links to the chapter that explains it.

ALanguage & types

C#RustWhere
class (data)struct + impl blockTypes
interfacetraitTraits
enum (named integers)enum with no payloadTypes
sealed hierarchy / DUenum with per-variant dataTypes
null / T?Option<T>Types
switch expressionmatch (exhaustive)Types
var (mutable by default)let (immutable; let mut to opt in)Types
string / ReadOnlySpan<char>String / &strTypes
List<T> / Dictionary<K,V>Vec<T> / HashMap<K,V>Types
where T : IFoo<T: Foo> / impl FooTraits
List<IFoo> (mixed types)Vec<Box<dyn Foo>>Traits
extension methodsimpl Trait for a foreign typeTraits
record equality / ToString#[derive(PartialEq, Debug, …)]Traits

BMemory & ownership

C#RustWhere
garbage collectorownership + the borrow checkerOwnership
using / IDisposable.Dispose()Drop (runs at end of scope)Ownership
reference assignment (aliasing)move semantics; explicit .clone()Ownership
passing by referenceborrowing: &T / &mut TOwnership
heap object / shared handleBox<T> / Rc<T> / Arc<T>Ownership
reflexive defensive copiesborrow instead of .clone()Perf

CConcurrency & shared state

C#RustWhere
lock (obj) { }Mutex<T> (std / parking_lot)Concurrency
ReaderWriterLockSlimRwLock<T>Concurrency
ConcurrentDictionary<K,V>DashMap / Arc<RwLock<HashMap>>Concurrency
Interlocked.*AtomicU64 & friends (+ Ordering)Concurrency
Lazy<T>LazyLock<T> / OnceLock<T>Concurrency
SemaphoreSlimtokio::sync::SemaphoreConcurrency
volatile / Volatile.Read/Writeatomic load/store with an OrderingConcurrency

DError handling

C#RustWhere
exceptionsResult<T, E>Errors
try/catch + rethrowthe ? operatorErrors
throw for impossible statespanic! / .unwrap() / .expect()Errors
custom exception classesthiserror error enumsErrors
catch Exception at the topanyhowErrors

EAsync

C#RustWhere
Task<T> / asyncFuture / async fn (lazy)Async
await xx.await (postfix)Async
the thread pool / schedulerthe tokio runtimeAsync
Task.Runtokio::spawnAsync
Task.WhenAll / WhenAnytokio::join! / tokio::select!Async
CancellationTokentokio_util CancellationToken + select!Concurrency

FTooling & build

C#RustWhere
dotnet CLI + NuGetcargo + crates.ioSetup
.csproj / PackageReferenceCargo.toml / [dependencies]Setup
Roslyn analyzerscargo clippyPractices
dotnet format / dotnet testcargo fmt / cargo testPractices
dotnet build -c Releasecargo build --releaseBuild
self-contained / single-file / AOT publishthe default build; musl for fully staticBuild

GWeb APIs & auth

C# / ASP.NET CoreRust / axumWhere
minimal API / controller actionhandler fn returning impl IntoResponseAuth
model binding ([FromBody] / [FromRoute])extractors (Json<T> / Path<T> / Query<T>)Auth
System.Text.Jsonserde / serde_jsonAuth
DataAnnotations / FluentValidationvalidator crateAuth
exception filter / ProblemDetailsimpl IntoResponse for one error typeAuth
[Authorize] + ClaimsPrincipalFromRequestParts extractor → CurrentUserAuth
[Authorize(Roles=…)] / policiesguard extractor (e.g. AdminUser)Auth
JwtBearer handlerjsonwebtoken crateAuth
middleware pipeline (UseCors, …)tower layers (CorsLayer, TraceLayer)Auth
password hashing (Identity)argon2 / bcrypt crateAuth