Skip to content
Select theme

About

Hacking with Rust is a tutorial site for people who are learning Rust — or using Rust and getting stuck on the parts that are genuinely hard.

Each article answers one question. It is written as a search result: you had a specific problem, you found the page, it gives you the working code and explains why it works.

Two rules apply to everything published here:

  1. Every code example is compiled and tested. If a snippet is supposed to fail to compile, the page shows the real rustc output, including the error code and the compiler’s own suggested fix.
  2. No “just use clone()” hand-waving. Where multiple fixes exist, the page explains the trade-off, because copying a value to silence the borrow checker is often the wrong answer.
  • Developers coming from Python, JavaScript, Go, C++ or Java who understand programming but not Rust’s ownership model.
  • Students and self-taught programmers working through their first systems language.
  • Rust users who are productive most days, but hit a wall every time lifetimes get involved.

If you have never programmed before, this site is a supplement rather than a starting point — work through The Rust Book alongside it.

Spotted a mistake, an outdated compiler message, or an example that no longer compiles? That matters here more than almost anywhere else, because the whole claim of this site is that the code runs. Mail hello@hackingwithrust.com with the page and what is wrong with it, and it gets fixed.