Pages

Topics

Tools

↑↓navigate↵openescclose

Rust guides

Every published Rust guide, newest first, with practical examples you can copy into your own project.

3,815 guides across 14 topics

Topics

Latest Rust guides

3D illustration of a self-referential struct anchored in heap memory by a Pin lock
Rust

Rust Pin and Unpin: Memory Pinning, Self-Referential Structs, and Futures

Why a future must not move after polling starts, what Unpin opts out of, and how Box::pin, pin! and map_unchecked_mut express that guarantee.

RustAsyncMemory Safety
3D illustration of safe abstraction shields wrapping an isolated unsafe FFI boundary
Rust

Rust Unsafe: Raw Pointers, FFI Bindings, and Soundness Invariants

What unsafe actually unlocks, the five soundness contracts behind raw pointers, and the FFI rules for repr(C), CString and unwinding.

RustUnsafeFFI
3D illustration of a fixed stack array contrasted with a fat-pointer slice view over contiguous memory
Rust

Rust Arrays and Slices: Fixed Arrays, &[T] Fat Pointers, and DSTs

An array carries its length in its type; a slice carries it in the pointer. The split_at_mut, chunks and TryFrom patterns that follow from that.

RustSlicesMemory Safety
3D illustration of Cargo test runner lanes validating unit, integration and doc examples
Rust

Rust Testing: Unit Tests, Integration Tests, and Cargo Doc Tests

Three test kinds with three different visibility rules, plus the commands, attributes and doc-test fences that make cargo test useful.

RustTestingCargo
3D illustration of typed Rust structs serialising into structured JSON payloads through Serde attributes
Rust

Rust Serde: JSON Serialization, Derive Macros, and Field Attributes

Serde attributes decide the wire format: rename strategies, defaults, flatten, enum tags and custom codecs, plus the number and ordering traps.

RustSerdeJSON
3D illustration of token streams expanding into AST syntax trees through a macro hygiene filter
Rust

Rust Macros: macro_rules! Patterns, Hygiene, and Procedural Macros

Matcher fragments, repetition, hygiene and the proc-macro crate. How to read a macro_rules! error and when a derive macro is the right tool.

RustMacrosMetaprogramming
3D illustration of heap-allocated String buffers linked to borrowed UTF-8 fat-pointer slices
Rust

Rust Strings Explained: &str vs String, UTF-8 Indexing, and Conversions

Why s[0] does not compile, why slicing can panic, and when a &str becomes an owned String. The UTF-8 rules behind every Rust string error.

RustStringsMemory Management
3D illustration of contiguous Vec buffers, hash-bucketed HashMap tables and ordered BTreeMap nodes side by side
Rust

Rust Collections: Vec, HashMap, BTreeMap, and the Entry API

Vec for sequences, HashMap for keyed lookup, BTreeMap for order. Where the Entry API removes a lookup, and why index removal is O(n).

RustCollectionsData Structures
3D illustration of a Cargo workspace crate tree with module boundaries and public visibility gates
Rust

Rust Modules and Crates: mod, pub Visibility, use Paths, and Workspaces

Modules decide privacy, crates decide compilation, workspaces decide sharing. The file layout, visibility levels and Cargo wiring that hold them together.

RustModulesCargo
3D illustration of generic type parameters branching into specialised machine-code blocks with a where-clause filter
Rust

Rust Generics: Type Parameters, Where Clauses, and Monomorphization

How generics become zero-cost code, why where clauses are not cosmetic, and how monomorphization turns one function into many.

RustGenericsSyntax