Skip to content

Learn You a Rust for Greater Good!

🦀

Learn You a Rust

for Greater Good!

So you’ve decided to learn Rust. Maybe a friend wouldn’t stop talking about it. Maybe your build at work is segfaulting at 2am and you’d like, just once, for the computer to tell you you’re holding it wrong before it explodes. Maybe somebody on the internet called your favourite language “memory unsafe” and you’d like to respond with something stronger than “you take that back.”

Whatever the reason: welcome. Pour yourself a drink, put on the sweater your grandma made you, and let’s get oxidized.

What is this thing?

It’s a book. A web book. A webook? No. It’s a book on a website, in the cheerful tradition of Learn You a Haskell for Great Good!, to which this site owes most of its personality and roughly 0% of its ML-style type theory.

The pitch is simple: every code example you see, you can run. Edit it. Break it. Make it print rude words. Click “Run” and it’ll go off and compile against the real rustc (via play.rust-lang.org) and bring back the output — errors, panics, and all. The borrow checker will be there. It wouldn’t miss it.

🦀 main.rs

The table of contents (such as it is)

A note on the playground

Every editor on this site talks to the official Rust Playground. The first time you Run something it’ll take a half-second or so; after that we cache the result in your tab so re-runs are instant. There’s an ”↗ Playground” button on every editor too — it’ll dump the snippet into a fresh tab over at play.rust-lang.org so you can mess with it without losing your place.

If your internet is down, the editor still works, the highlighting still works, and you can still pretend to compile things with your mouth.

Ready? Onward.