Rust¶
Rust is a systems programming language focused on performance, reliability, and memory safety without a garbage collector. Its ownership model, checked at compile time, eliminates whole classes of bugs (use-after-free, double frees, data races) while still compiling to fast native code. Paired with Cargo, its build tool and package manager, it's well suited to CLIs, network services, infrastructure tooling, and anything where correctness and speed both matter.
Guides¶
Fundamentals¶
- Understanding Ownership, Moves, and Borrowing
The core mental model behind Rust: scope and drop, moves, shared and mutable references, the borrowing rules,
Copyvs.Clone, slices, lifetimes, and smart pointers likeRc,Arc, andMutex. Includes a table of the most common ownership-related compiler errors and a checklist for working through them. - Worked example: partial moves in a
match: compiler error E0382 inside amatch, why binding a field in a pattern moves it, what the compiler'srefsuggestion really means, and five idiomatic fixes.
Project structure, architecture, and deployment¶
- Structuring and Architecting Rust Projects: A Comprehensive Guide The complete lifecycle of a Rust project, in six parts:
- Project structure: crates, modules, and workspaces; repository layouts for a CLI, a web service, and a multi-tool workspace; root files;
Cargo.tomland toolchain config. - Application architecture: layering with traits at the boundaries, ownership-driven design, configuration, error handling, logging, async, CLI and axum service design, persistence and migrations.
- Core coding concepts: type-driven design, traits, iterators, strings and paths, pattern matching, builders, concurrency, macros,
unsafe, performance. - Quality and supply chain: testing, documentation, tooling, git hooks,
cargo deny, choosing dependencies, API stability. - Build, deploy, and release: versioning, release builds, the Makefile, Dockerfile, Compose, Helm chart, systemd units, GitLab CI, and releases.
- Anti-patterns and a new-project checklist.
Suggested reading order¶
- Start with Ownership, Moves, and Borrowing. Nearly everything else in Rust builds on it.
- Keep its partial-move worked example handy for when the borrow checker objects to a
match. - Read Structuring and Architecting Rust Projects before starting your next non-trivial project, and use its checklist when setting one up.
External resources¶
- The Rust Programming Language: the official book
- Rust by Example: learn through annotated, runnable examples
- The Cargo Book: builds, dependencies, workspaces, and features
- Rust API Guidelines: conventions for idiomatic APIs
- Standard library docs
- Rust Playground: run snippets in the browser