Reference · look it up
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.
| C# | Rust | Where |
|---|---|---|
class (data) | struct + impl block | Types |
interface | trait | Traits |
enum (named integers) | enum with no payload | Types |
| sealed hierarchy / DU | enum with per-variant data | Types |
null / T? | Option<T> | Types |
switch expression | match (exhaustive) | Types |
var (mutable by default) | let (immutable; let mut to opt in) | Types |
string / ReadOnlySpan<char> | String / &str | Types |
List<T> / Dictionary<K,V> | Vec<T> / HashMap<K,V> | Types |
where T : IFoo | <T: Foo> / impl Foo | Traits |
List<IFoo> (mixed types) | Vec<Box<dyn Foo>> | Traits |
| extension methods | impl Trait for a foreign type | Traits |
record equality / ToString | #[derive(PartialEq, Debug, …)] | Traits |
| C# | Rust | Where |
|---|---|---|
| garbage collector | ownership + the borrow checker | Ownership |
using / IDisposable.Dispose() | Drop (runs at end of scope) | Ownership |
| reference assignment (aliasing) | move semantics; explicit .clone() | Ownership |
| passing by reference | borrowing: &T / &mut T | Ownership |
| heap object / shared handle | Box<T> / Rc<T> / Arc<T> | Ownership |
| reflexive defensive copies | borrow instead of .clone() | Perf |
| C# | Rust | Where |
|---|---|---|
lock (obj) { } | Mutex<T> (std / parking_lot) | Concurrency |
ReaderWriterLockSlim | RwLock<T> | Concurrency |
ConcurrentDictionary<K,V> | DashMap / Arc<RwLock<HashMap>> | Concurrency |
Interlocked.* | AtomicU64 & friends (+ Ordering) | Concurrency |
Lazy<T> | LazyLock<T> / OnceLock<T> | Concurrency |
SemaphoreSlim | tokio::sync::Semaphore | Concurrency |
volatile / Volatile.Read/Write | atomic load/store with an Ordering | Concurrency |
| C# | Rust | Where |
|---|---|---|
| exceptions | Result<T, E> | Errors |
try/catch + rethrow | the ? operator | Errors |
throw for impossible states | panic! / .unwrap() / .expect() | Errors |
| custom exception classes | thiserror error enums | Errors |
catch Exception at the top | anyhow | Errors |
| C# | Rust | Where |
|---|---|---|
Task<T> / async | Future / async fn (lazy) | Async |
await x | x.await (postfix) | Async |
| the thread pool / scheduler | the tokio runtime | Async |
Task.Run | tokio::spawn | Async |
Task.WhenAll / WhenAny | tokio::join! / tokio::select! | Async |
CancellationToken | tokio_util CancellationToken + select! | Concurrency |
| C# | Rust | Where |
|---|---|---|
dotnet CLI + NuGet | cargo + crates.io | Setup |
.csproj / PackageReference | Cargo.toml / [dependencies] | Setup |
| Roslyn analyzers | cargo clippy | Practices |
dotnet format / dotnet test | cargo fmt / cargo test | Practices |
dotnet build -c Release | cargo build --release | Build |
| self-contained / single-file / AOT publish | the default build; musl for fully static | Build |
| C# / ASP.NET Core | Rust / axum | Where |
|---|---|---|
| minimal API / controller action | handler fn returning impl IntoResponse | Auth |
model binding ([FromBody] / [FromRoute]) | extractors (Json<T> / Path<T> / Query<T>) | Auth |
System.Text.Json | serde / serde_json | Auth |
| DataAnnotations / FluentValidation | validator crate | Auth |
exception filter / ProblemDetails | impl IntoResponse for one error type | Auth |
[Authorize] + ClaimsPrincipal | FromRequestParts extractor → CurrentUser | Auth |
[Authorize(Roles=…)] / policies | guard extractor (e.g. AdminUser) | Auth |
| JwtBearer handler | jsonwebtoken crate | Auth |
middleware pipeline (UseCors, …) | tower layers (CorsLayer, TraceLayer) | Auth |
| password hashing (Identity) | argon2 / bcrypt crate | Auth |