The Rust Spellbook (early access)

The Rust Spellbook (early access)

$29.95

Deepen your wizardry with dozens of tips, tricks, techniques, and tactics for writing better Rust programs.

Add To Cart

The Rust Spellbook

The Rust Spellbook is a compilation of my personal favorite things I've learned about Rust, including language features, hidden bonuses, neat tricks, good practices, obscure but useful options, and fascinating facts. Some of these “spells” I use all the time as a working Rust programmer. Others I use more rarely, but I'm still glad to know about them: you never know when the perfect use case might arise. Others I'll probably never use or can't imagine needing to use, but they’re still fun to know about, and I'm sure somebody somewhere will be overjoyed to discover them: “This solves my exact problem!”

You don't need to be a highly experienced Rust developer to enjoy this book. In fact, the less experience you have, the more of it will be new to you. Old Rust hands may already be familiar with some of the spells described here, but many others will be a lightbulb moment. My goal is that there should be something fun and interesting for everybody: no matter what your current level of Rust knowledge, this book will deepen and extend it.

And if you haven’t used Rust yet, perhaps this book will inspire you to give it a try, when you find out about all the neat things you can do with Rust. There's really something magical about it. So let's get started!

This is the early access version, containing about a third of the final book. You’ll get free updates as each new chapter is published, and free updates to the final release version for life.

Table of contents

Read a sample chapter

Who the book is for

Every Rust programmer will enjoy this book (I sincerely hope). As I mentioned, there’s something for everybody, from complete beginners to heavily-corroded Rustaceans who think they’ve seen it all. There’s always more to know! Many of the spells will be useful no matter what your level of Rust experience. Most of them will come in handy some day, even if it’s not today. And all of them are interesting and fun to know.

The magic of Rust

Programming is fun, as I've often remarked, and programming in Rust is especially fun because it's such a rich, expressive, and elegant language. If you've done a little programming in Rust already, you'll know exactly what I mean. If you haven't, you soon will.

Rust also has an amazing standard library. Its small set of core data types is incredibly flexible and useful. For example, everybody's favourite, Vec, currently has 63 methods and implements 81 traits. The odds are, whatever you want to do with your Vec, you'll find it somewhere in those lists.

The tooling provided for Rust developers is also second to none. Cargo provides about 40 built-in commands for building, testing, managing, or publishing your Rust crates, and dozens more are provided by plugins.

And in the wider Rust ecosystem, there are over 200,000 published crates that you can download and use as part of your own programs. Rust programs can be built for hundreds of platforms and dozens of operating systems, or even platforms with no operating system at all.

Rust runs on computers, phones, tablets, cars, ships, spacecraft, washing machines, TVs, watches, medical devices, cameras, security systems, microwaves, and every other kind of device you can think of (and some you can't). It's a critical part of the infrastructure of companies like Amazon, Google, Meta, Apple, and Netflix. Year after year, it's voted the most loved language by software developers.

Long story short, Rust is magic.

What you’ll learn

Among the many powerful and useful spells in this bumper fun grimoire of Rust, you’ll find:

  • How to avoid crashes and wrong answers by using Rust’s checked arithmetic methods

  • How to use editions, features, preludes, examples, and doctests to publish great Rust crates

  • How to manage, query, and optimise your dependencies for efficient builds

  • Understanding the options for rounding floating-point values in Rust, and how they work

  • How to embed data from files and environment values into your Rust programs

  • Writing inline assembly code for maximum performance or to use CPU-specific features

  • All about Rust’s release channels and toolchains

  • Safely converting between numeric types, without shooting yourself in the foot

  • Mastering the dark arcana of Cargo.toml: local crates, Git repos, and alternate registries

If you like the book’s approach, you might be interested in studying with me directly, through my professional mentoring program, or booking some live Rust training for your team.

What you get

Your digital download is a ZIP file containing the book in PDF and ePub formats. These should be suitable for any ebook reader, Kindle, computer, phone, or tablet.

Updating to the latest edition

All my books come with free updates for life, so if you’ve bought a previous version of this book, here’s what you need to do to get the latest edition. Click the link in your original download email (make sure you save this, as it’s your key to future updates). You’ll see what looks like an error page saying your download link for the old edition has expired, but that’s okay: click the link in the text, and you’ll be sent a new download email for the current edition.

More resources

See also my Rust training and team training sessions, books, and tutorials—and please subscribe to my free newsletter for lots more!

Readers say

Muzher Sharif, Biopharma AI/ML Engineer, GSK

“Brilliant!”

The book flows very nicely, with really clear language throughout.

Stephen Adams, Principal Software Engineer, Red Hat

“Clear explanations, even for newbies!”

I've just finished reading the book and felt that it was well written and explained the concepts clearly, even for me as a newbie to Rust.

The Secrets of Rust: Tools

The Secrets of Rust: Tools

$29.95