Overview
Rust Mastery loads Rust's founding bet into your agent: the safe code and the fast code are the same code. The doctrine has two reinforcing halves — don't fight the borrow checker, redesign until it agrees; and measure, then remove work. The core file carries fifteen non-negotiables and two decision frameworks (the ownership ladder and performance triage); nine reference files go deep on ownership and borrowing, type-driven design, error handling, the full optimization toolbox (profiles, allocation discipline, layout, SIMD, rayon), concurrency and async/tokio, disciplined unsafe with Miri, crate API design, testing, and decoding compiler errors — loaded only when the task needs them.
What it grants
- 01The ownership ladder: restructure > borrow > deliberate clone > Rc/Arc > unsafe — with the fight catalog for each borrow-checker classic
- 02Performance triage in order of leverage: release profiles, algorithms, allocations, copies, contention, rayon, micro
- 03Allocation discipline: with_capacity, buffer reuse, iterator fusion, arenas, small-vec — the everyday wins
- 04Profiling as doctrine: criterion, flamegraphs, dhat, hyperfine — no optimization without a before/after in --release
- 05Type-driven design: illegal states unrepresentable, newtypes, typestate, generics vs dyn dispatch decided by data
- 06Errors as API: thiserror for libraries, anyhow for apps, panic policy, matchable variants
- 07Fearless concurrency with discipline: locks never held across .await, cancellation-aware async, rayon vs tokio by workload
- 08unsafe as a contract: SAFETY comments, safe wrappers, the UB catalog, Miri and fuzzing in CI, FFI mechanics
- 09Crate craft: API signatures that borrow, additive features, semver discipline, doc tests on every public item
- 10Compiler-error decoder ring: E0382/E0502/'not Send' surgically fixed, plus build-speed and footgun checklists
Try it like this
agent> Profile and fix this hot path the rust-mastery way — release build, kill the allocations, justify every clone, and prove the wins with criterion.