Rust Language
A concise guide to Rust’s core features, focusing on practical skills for modern, reliable systems development.
Rust gives developers a fast, dependable foundation for building modern systems, and this guide focuses directly on the practical skills you’ll use every day. Instead of covering the language’s background or evolution, we’ll move straight into the core features that matter for real-world development.
These tutorials assume basic Rust familiarity — you can write a struct, use match, and read a function signature. The focus is on idiomatic patterns, best practices, and common scenarios encountered in production code.
Learning Path
- Working With the Borrow Checker — common ownership scenarios and the patterns that resolve them
- Iterators Over Loops — when and how to use iterator chains idiomatically
- Error Handling in Practice —
Result,?, and real error management - Strings: Choosing the Right Type —
&str,String, andCow<str> - Smart Pointers Demystified —
Box,Rc,Arcthrough concrete use cases - Trait Objects vs Generics — when to use
dyn Traitvs<T: Trait> - Lifetimes in Practice — when annotations are needed and the patterns that resolve them
- Concurrency in Practice — threads,
Send/Sync, channels, and the deadlocks to avoid - Async/Await with Tokio — futures, the runtime, spawning tasks, and avoiding blocking calls
- Closures and Fn Traits — capturing the environment,
FnOnce/FnMut/Fn, and returning closures - Testing in Practice — unit vs integration tests, mocking with traits, and test fixtures
- Collections Deep Dive —
Vec,HashMapvsBTreeMap, theEntryAPI, andVecDeque - Pattern Matching Deep Dive — guards,
@bindings, or-patterns, andlet else - Derive Macros and Common Traits — what
Debug,Clone,Eq,Hash,Ord, andDefaultactually generate, and when to hand-implement instead - Newtype Pattern and From/Into Conversions — type-safe wrappers, the orphan rule, and idiomatic conversions
- Builder Pattern and Typestate — fluent builders, required fields, and encoding valid state transitions in the type system
- Operator Overloading —
std::opstraits, avoiding forced clones, and when an operator is the wrong choice - Implementing Your Own Iterator — the
Iterator/IntoIteratortraits,size_hint, and well-behaved exhaustion - Serde and JSON in Practice — field renaming, optional fields, custom formats, and tagged enums
- Unsafe Rust Basics — what
unsafeactually unlocks, raw pointers, and wrapping unsafety in a safe API - Modules and Project Organization — visibility levels, re-exporting, and when to split into a workspace
- Generics and Trait Bounds Deep Dive —
whereclauses, conditional and blanket impls, and associated types - Declarative Macros (macro_rules!) — matching syntax, fragment specifiers, repetition, hygiene, and when not to reach for a macro
- Drop, RAII, and Resource Cleanup — the
Droptrait, drop order, early drop, guard patterns, and suppressing cleanup - Cargo Features and Conditional Compilation — feature flags, optional dependencies,
#[cfg], and feature unification - FFI — Calling C from Rust —
externblocks,#[repr(C)], string conversion, and ownership across the boundary - Const Generics and const fn — parameterizing over values, compile-time evaluation, and the const subset
- Trait Inheritance and Supertraits — supertrait bounds, default methods, and composing small traits
- Performance and Avoiding Allocations — measuring first, the
.clone()reflex, capacity reservation, andCow - Error Libraries — thiserror and anyhow —
#[from]conversion, source chains,.context(), and downcasting - Logging and Tracing — the
logfacade,tracingspans, structured fields, and#[instrument] - Building CLIs with clap — the derive API, positionals/options/flags, subcommands as enums, and type-driven validation
- Interior Mutability —
Cell,RefCell,Mutex/RwLock, andOnceLock/LazyLockfor mutating behind&self - Deref, AsRef, and Borrow — deref coercion, flexible
AsRefparameters, and theBorrowkey-lookup trick - Data Parallelism with Rayon —
par_iter(),join/scope, parallel sort, and when the overhead isn't worth it - Procedural Macros — derive/attribute/function-like macros, the
syn+quoteworkflow, and spanned errors - Async Channels and select! —
mpsc/oneshot/broadcast/watch, racing futures withselect!, and drop-as-cancellation - Sealed Traits and API Evolution — sealed traits,
#[non_exhaustive], and what is/isn't a semver break - TryFrom and Fallible Conversions —
TryFrom/TryInto, theFromvsTryFromsplit, and "parse, don't validate" - PhantomData and Marker Types — zero-sized markers,
PhantomData, and compile-time units/state machines - Slices, Chunks, and Windows —
&[T]views,chunks/windows,split_at_mut, andbinary_search - Send and Sync Deep Dive — the two thread-safety auto traits, why
Rc/RefCellopt out, and theSend + 'staticspawn bound - Iterator Adapters Deep Dive —
scan,peekable,take_while,zip/chain/step_by, andpartition/unzip - Build Scripts (build.rs) — running code before compilation,
cargo:directives,OUT_DIRcodegen, and rebuild tracking - Option and Result Combinators —
map/and_then, bridging withok_or, and the eager-vs-lazy_or_elsetrap - Enums as State Machines — replacing boolean soup with data-carrying variants and self-consuming transitions
- Sorting and Ordering —
sort_by_key/sort_by, stable vs unstable,Ordderivation, floats, and multi-key sorts - Default and Construction — the
Defaulttrait,..Default::default()struct-update, and when to prefer a builder - The Read and Write Traits — unified byte I/O,
BufReader/BufWriter, the flush trap, and genericimpl Read/impl Write - Working with Time —
InstantvsSystemTime,Durationarithmetic without panics, and wherechronobegins - Trait Method Resolution — inherent-vs-trait priority, auto-ref/deref, ambiguity, and fully-qualified syntax
- Custom Hash and Eq — the
Hash/Eqcontract, hashing a subset of fields, and newtype keys - FromIterator and collect — how
collectpicks its type, collecting intoResult/HashMap/String, and custom targets - Cargo Dependency Management — version ranges, the lockfile, duplicate versions, and feature unification across the tree
- Type Aliases and Associated Constants — aliases vs newtypes,
type Result<T>, and constants attached to types and traits - Exit Codes and Process Control —
mainreturn types,ExitCode, theprocess::exitdestructor trap, and reading the environment - The Never Type —
!, the coercion rule behindpanic!/returnin expressions, the divergence macros, andInfallible - Function Pointers vs Closures —
fnpointers vsFnclosures, the non-capturing coercion, and where each fits - Formatting: Display and Debug —
DebugvsDisplay, implementingfmt, the format-spec language, and inline capture - Documentation and Doctests —
///vs//!, examples tested bycargo test, hiding setup, and doc conventions - Filesystem and Paths —
Path/PathBuf, portablejoin, non-UTF-8 paths, andstd::fsread/write - Pin and Self-Referential Types — why futures can't move,
Pin/Unpin, andBox::pin/pin!in practice
By Theme
Prefer to explore by area? The same tutorials grouped by topic. The numbered path above is the recommended reading order; each tutorial links back to any it builds on.
Ownership, Borrowing & Memory — Borrow Checker · Strings · Smart Pointers · Lifetimes · Drop & RAII · Interior Mutability
Traits, Generics & Conversions — Trait Objects vs Generics · Newtype & Conversions · Operator Overloading · Generics & Trait Bounds · Const Generics · Supertraits · Deref, AsRef & Borrow · Sealed Traits · TryFrom · Method Resolution · Type Aliases & Assoc Consts
Iterators & Closures — Iterators Over Loops · Closures & Fn Traits · Implementing an Iterator · Iterator Adapters · FromIterator & collect · Function Pointers vs Closures
Error Handling — Error Handling in Practice · thiserror & anyhow · Option/Result Combinators · The Never Type
Data Modeling & Pattern Matching — Pattern Matching · Builder & Typestate · PhantomData & Markers · Enums as State Machines · Default & Construction
Collections & Data Structures — Collections · Slices, Chunks & Windows · Sorting & Ordering · Custom Hash & Eq
Concurrency & Async — Concurrency · Async/Await with Tokio · Data Parallelism with Rayon · Async Channels & select! · Send & Sync · Pin
Macros & Metaprogramming — Derive Macros · Declarative Macros · Procedural Macros
Systems & I/O — Serde & JSON · Unsafe Rust · FFI · Read & Write · Working with Time · Exit Codes & Process · Filesystem & Paths
Project, Tooling & Observability — Testing · Modules & Organization · Cargo Features · Performance · Logging & Tracing · CLIs with clap · Build Scripts · Cargo Dependencies · Formatting · Docs & Doctests