
Rust Performance Basics Measure First Then Change One Thing
The handful of habits behind most Rust speed: build in release, avoid needless allocation, use iterators and slices, pick the right collection and measure before tuning.
Everything you need to level up your coding skills.

The handful of habits behind most Rust speed: build in release, avoid needless allocation, use iterators and slices, pick the right collection and measure before tuning.

The orphan rule says you can implement a trait only if the trait or the type is yours. See why it exists, the usual errors and the standard workarounds.

Pin the Rust version, components and targets for a project with rust-toolchain.toml so every laptop and CI job builds the same way. Covers channel choices and the file format.

A blanket implementation implements a trait for every type that meets a bound. See how ToString and Into work, the coherence rules that limit you and a safe pattern.

Put the business rules in the middle, describe what they need as traits (ports) and plug in databases and HTTP as adapters. A complete small example with a test double.

A supertrait says a trait requires another one. See the syntax, how methods are inherited, trait objects with supertraits and upcasting.

Version your schema with sqlx migrate: create files, run them at startup or in CI, embed them in the binary and handle the checksum error when a file changes.

no_std removes the standard library and leaves core. See what you lose, what core and alloc still give you, and how to write crates that work both ways.

Box<dyn Trait> costs one allocation and one indirect call per use. Learn what that costs, when it is worth it and the cheaper alternatives.

Dyn compatibility is the set of rules a trait must meet to be used as dyn Trait. Learn each rule, the error it produces and how to keep a trait usable.

Axum routes map a path and method to an async function. Learn path parameters, nesting, fallbacks and the 0.8 syntax change for captures.

A trait object is a pointer plus a vtable, which lets one Vec hold many types. See how to build one, what the cost is, and why some traits cannot be used this way.
We send one email when a new post is published. No spam.