Rust Cheat Sheet
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. The reference material consulted while preparing these pages is listed in the section bibliography. |
A single-page, colour-coded summary of the Rust language, written against Rust 1.99.0 and the 2024 edition (checked
2026-10-06) — the rustup and cargo command map and a Cargo.toml skeleton with features, profiles, [lints] and a
workspace, primitive types, literals and casts, let/mut/const/static and shadowing, control flow with loop values,
labels, if let, let-else and let chains, the ownership and borrowing rules in one box with the lifetime elision
rules, structs, enums and pattern syntax, Option/Result combinators and ? with an error-type recipe, collection,
string and iterator one-liners, generics versus impl Trait versus dyn Trait, closures and the Fn traits, a
smart-pointer and interior-mutability chooser, the Send/Sync table, threads, channels and async, modules and
visibility, macro_rules! fragment specifiers, the unsafe superpowers, testing and tooling flags, and a strip of what
changed since older tutorials — handy for quick memorization or as a
downloadable PDF desk reference.
For the full explanation, every option, and additional examples, see the dedicated pages:
Start here — Rust Reference.
Getting started — Getting Started, Toolchain, rustup & Editions and Syntax, Comments & Style.
Core language — Variables, Mutability & Constants, Types & Values, Functions & Expressions and Control Flow.
Ownership — Ownership & Moves, Borrowing & References, Slices & Dynamically Sized Types and Lifetimes.
Data and errors — Structs & Methods, Enums & Pattern Matching, Option, Result & Combinators, Error Handling, Collections and Strings & Text.
Abstraction — Generics & Const Generics, Traits, Trait Objects & dyn Compatibility, Any & Downcasting, Closures & Fn Traits, Iterators, Type Conversions & Coercions and Standard Traits & Operator Overloading.
Memory — Smart Pointers, Interior Mutability & Lazy Initialization, Drop, RAII & Drop Check and Memory Layout & repr.
Concurrency and async — Threads & Message Passing, Shared State, Send/Sync & Atomics, Data Parallelism with Rayon, Async/Await & Futures, Pin & Unpin and Async Runtimes & Tokio.
Code organization and tooling — Modules, Crates & Visibility, Cargo & Workspaces, Testing & Benchmarking, Documentation with rustdoc, Tooling: Clippy, rustfmt & rust-analyzer and Debugging & Diagnostics.
Advanced and interop — Macros, Unsafe Rust, FFI & C Interop, Python Interop with PyO3 and WebAssembly.
References
The PDF summarizes the official documentation; each source is cited in full on the page listed above that covers it, and in the section bibliography.