Leanpub Header

Skip to main content

Topics

Rust

From ownership and the borrow checker to traits, async and the compiler's own pipeline, and on to servers, WebAssembly and neural networks, the Rust language as told through the free samples of the Leanpub books about it.

Created from the free samples of 9 Leanpub books and the descriptions and tables of contents of 15 more, with every source cited.

Rust is a compiled, statically typed systems programming language that aims at the speed and control of C and C++ without their memory-safety bugs, and without a garbage collector or runtime to pay for the safety. Its central idea is ownership: every value has one owner, references to it are borrowed under rules the compiler checks, and a program in which a reference could outlive its value, or two parts could write the same data at once, does not compile. One of the library's books states the bargain Rust set out to break as the choice between C-level speed with memory corruption and data races, or managed-language safety with garbage-collection pauses and heavy runtimes.[15] Another names the language's other organising decision: almost every feature, from the plus operator and the for loop to the question-mark operator, closures and async/await, is defined in terms of a trait that any type can implement.[1]

By 2026 the language runs in places that were once C's alone. One description says Rust now runs in the Windows kernel, powers production services at the largest cloud providers and ships in everything from microcontrollers to WebAssembly edge runtimes;[15] another surveys where it has settled: Python extensions through PyO3, the browser through WebAssembly and bare-metal embedded targets.[14] A book on serverless WebAssembly chooses Rust because, its author says, the two grew up together and the developer experience shows it.[9] Around the language sit Cargo, its package manager and build tool, and the crates the library's books lean on throughout: Tokio for async I/O, Axum for the web, SQLx, Serde and Rayon.[12][2]

This article follows the subject outward from the language: where to begin, the history, ownership and memory, traits and iterators, concurrency, what the compiler and the processor do with the code, the things being built in Rust, and how a Rust program is debugged. Its sources are the free samples of the Leanpub books listed at the end, with the descriptions and tables of contents of the books whose samples were not available, and every claim that rests on a source is cited to it. Rust is a young shelf on Leanpub, most of it published in 2025 and 2026, so this is a shorter article than the library's older languages get.

Where to start

For a reader who has never programmed, Welcome to Rust is written for the absolute beginner and uses Rust as a first language, taught through stories, simple examples and exercises; its free sample is the back matter, a cheat sheet, a list of common compiler errors with their fixes and a glossary.[6] Every other book in the pool assumes a programmer. Rust Concepts asks for comfort in at least one other language and no Rust at all, and compares each decision with what C, Java, Python or Go would do;[1] Rust Programming grew out of training material for Python, C and C++ developers and runs to several hundred short sections with exercises and solutions.[13] Two books build on the reader's existing language: Rust for Java Developers explains every Rust idea by comparison with its Java counterpart, ownership against garbage collection, traits against interfaces,[11] and Rust for Javascript Developers does the same for JavaScript and TypeScript, Promises becoming Futures and npm becoming Cargo, and says no C, C++ or systems background is needed.[12]

For the developer who has tried Rust and stalled on ownership, Fearless Rust is addressed to exactly that reader, promising a mental model first and a route from imperfect first drafts to idiomatic code.[10] The two short SouthStone guides, Rust Programming in 2026 and Rust: The Complete Guide 2026 EDITION - MODERN SYSTEMS PROGRAMMING, are tours for working engineers who already know C, C++, Go, Python or JavaScript; both are under ninety pages, and neither has a sample or a table of contents to judge it by.[14][15]

Once the basics are in hand, the specialist books take over. Rust Patterns skips syntax entirely and assumes patterns and algorithms from other languages;[2] The Rust Iterator Cookbook is for developers who already know the language;[17] Rust Deep Dives wants a reader who has shipped real Rust code and can fix a borrow checker error without guessing;[3] and Processor Architecture with Rust is for Rust programmers who care about performance and have never looked below the compiler.[4]

History

Rust began in 2006 as a personal project of Graydon Hoare, then an engineer at Mozilla, which took it under its sponsorship in 2009 and announced it in 2010. The early language, which had garbage-collected pointers and lightweight tasks of its own, was reworked over the following years into the one that shipped as Rust 1.0 in May 2015, with ownership and borrowing checked at compile time and no runtime at all. Mozilla's experimental Servo browser engine was the first large program written in it, and parts of Servo reached Firefox in 2017. Since 1.0 the compiler has shipped every six weeks, with an edition every few years, 2015, 2018, 2021 and 2024, that can change syntax without breaking old crates. Async/await became stable in 2019. The Rust Foundation, formed in 2021 by Amazon, Google, Huawei, Microsoft and Mozilla, took over stewardship, and the Linux kernel merged its first Rust support at the end of 2022.

The books in the library describe the language's present rather than its past. One describes a 2026 in which Rust runs in the Windows kernel and at the largest cloud providers, and pins itself to the 2024 edition because the language, it says, has outgrown the smaller Rust of earlier books;[15] another lists the places Rust now lives, Python extensions through PyO3, the browser through WebAssembly and bare-metal boards, and offers itself to readers wondering why so much infrastructure is quietly being rewritten in it.[14] The shelf tells the same story: nearly everything on it was published in 2025 or 2026.

Ownership, borrowing and the borrow checker

Every Rust value has one owner; when the owner goes out of scope the value is dropped; and ownership moves on assignment unless the type is Copy. References borrow a value for a while, either any number of shared references or exactly one mutable one, and the borrow checker enforces the rule at compile time. The beginner's appendix in one book lists what this produces in practice: a value used after it has been moved, a second mutable borrow while the first is live, a returned reference with no lifetime specifier, a closure that captures a vector and may outlive it, each with its fix, borrow instead of move, let the first borrow end, write the lifetime, wrap the data in Arc and Mutex.[6] Rust Concepts presents ownership as the part of Rust with no real equivalent elsewhere and gives it a whole part, from stack and heap through move semantics, Copy and Clone, interior mutability, shared ownership and lifetimes, explained as guarantees rather than a wall of compiler errors.[1] Rust for Javascript Developers gives the shift from garbage collection to ownership a chapter of its own.[12]

Smart pointers and interior mutability

Beyond plain references sit the smart pointers: Box for a value on the heap, Rc and Arc for ownership shared and counted at runtime, single-threaded and atomic, RefCell and Mutex for mutation through a shared reference. The Accelerated Guide to Smart Pointers in Rust covers that set in 75 pages, calls smart pointers the essence of Rust's zero-cost abstraction philosophy, explains raw pointers for readers who have not met them, and links every example to the Rust playground.[16] Rust Patterns treats each as a pattern with a problem it solves. Its sample opens with Cow, clone-on-write, for a function that may or may not need to modify its input and allocates only when a change is needed; then Cell and RefCell, which move borrow checking from compile time to run time for the caches, counters and graph nodes that need mutation through a shared reference, with the advice to keep borrow scopes short; then Mutex and RwLock behind Arc for the same need across threads; and then Drop guards, so that a temporary file, a lock or a transaction is released when its guard goes out of scope, panic or not.[2]

What the memory looks like

Memory Thinking for Rust takes the lowest view. Its second edition is a slide deck with notes and source code, and its contents run from a philosophy of pointers and values, ownership trees, moves and drops, through static, stack and heap memory, fat pointers, slices and strings, struct and enum layout including the null-pointer optimisation, trait objects and their vtables, closures as structs with captured fields, smart pointers and pinning, each shown in WinDbg on Windows and GDB on Linux x64 and ARM64.[7] The same questions get the compiler's answer in Rust Deep Dives, which notes that an Option of a reference costs nothing because the compiler reuses the null bit pattern a reference can never have, and that a Box of a value is one pointer while a Box of a trait object is two.[3]

Traits, iterators and errors as values

Rust Concepts opens with the pattern it is organised around: Rust maps language features to traits. Writing a plus b calls Add::add; a for loop calls IntoIterator::into_iter and then next until the iterator is done; the question-mark operator converts errors through From; a closure is an anonymous struct that implements FnOnce, FnMut or Fn depending on what its body does with its captures. The syntax is the surface and the trait method is what runs.[1] Its first chapters set out the smaller surprises in the same spirit: no implicit numeric conversions, even between integer widths; variables immutable unless declared mut, with shadowing to rebind a name to a new type; blocks and if as expressions, so that a stray semicolon turns a function's result into the unit type; and loop as an expression that break can carry a value out of.[1]

Errors are values. Option replaces null and Result replaces exceptions, and both are handled by match or passed up with the question-mark operator. Rust for Java Developers presents them as type-safe alternatives to null and exceptions, with error handling without try-catch and custom error types,[11] and Rust Programming introduces them early, with a demonstration of None handling through Option and of Result with the question mark, in the order a course would use.[13]

Iterators are the language's main abstraction for loops and pipelines, and they are lazy: an adaptor such as map does nothing until a consumer pulls from it. The Rust Iterator Cookbook is 78 recipes on this one feature, from how iterators work and why map alone does nothing, through borrowing, mutating or consuming a collection and short-circuiting with take and find, to custom Iterator implementations, Rayon's parallel iterators, async streams and the itertools crate, with a chapter on when not to use iterators and 17 exercises.[17] Rust Deep Dives makes the performance claim concrete: a filter-and-sum written as an iterator chain and the same thing written as a loop compile to identical machine code at the highest optimisation level, which is the zero-cost abstraction promise kept.[3]

Concurrency and async

Rust's claim is fearless concurrency: the ownership rules that prevent dangling references also prevent data races, because a value can cross to another thread only if its type is Send, be shared only if it is Sync, and be mutated from several threads only through a lock or an atomic. Rust Patterns states it plainly, the type system makes racy code fail to compile, so shared mutable state across threads means Arc around Mutex or RwLock, a guard that unlocks when dropped, and the rules that follow: RwLock only when reads dominate and contention is measured, locks taken in one global order against deadlock, the lock held for the shortest time with the expensive work done outside it.[2] Rust for Java Developers sets Rust's compile-time race prevention against Java's runtime synchronisation.[11]

Asynchronous Rust is a separate layer. An async function compiles to a state machine with a field for every value that must survive an await point, driven by an executor through Future, Poll and Waker; Rust Deep Dives gives the transform, the executors and what a Waker actually wakes a part of its own,[3] and Rust Concepts takes concurrency and async as its fifth part.[1] In practice this means Tokio. Rust Projects - Write a Redis Clone builds a Redis-like server on it, from binding a TCP port and serving one client to many connections, the RESP protocol and its binary parsing, GET and SET, active and passive key expiry, and an actor model that, the description says, simplifies the management of shared resources; replication and transactions are planned.[18]

What the compiler and the processor do with the code

Two books by the same author look beneath the language. Rust Deep Dives follows one small function through the stages of rustc: lexing and parsing, lowering to HIR where for loops, if let and the question-mark operator are desugared and names resolved, THIR with every type filled in, MIR as a control-flow graph on which the borrow checker runs, which is why non-lexical lifetimes work, since the checker looks at where a borrow is last used rather than at its scope, then monomorphisation into LLVM IR, one copy of each generic function per concrete type, and finally machine code. It goes on to the incremental query system and its red-green algorithm, the codegen-units trade between build speed and optimisation, and what the opt-level settings actually do.[3]

Processor Architecture with Rust goes further down. Its first part builds the machine from logic gates up, through the ALU, registers, caches, pipelines, branch prediction, out-of-order execution and multi-core; its second applies the lessons in Rust, data layout, branchless code, SIMD, memory access patterns, atomics, allocators, profiling and four case studies. The sampled chapter on the ALU explains why integer division costs twenty to ninety cycles against one for addition, so the compiler replaces division by a power of two with a shift; why a comparison is a subtraction whose result is discarded and only the flags kept; and how two's complement lets one adder serve signed and unsigned values, which is why i8 and u8 differ only in interpretation, and why 127 plus 1 in an i8 wraps to minus 128, panicking in a debug build and wrapping silently in release.[4]

Building things in Rust

Half the pool is project books, and together they map where the language is being used.

Servers, tools and templates

Rust for Javascript Developers builds a command-line tool, a web server with Axum, a database layer with SQLx and serialisation with Serde before compiling Rust to WebAssembly and calling it from JavaScript, with chapters ending in a comparison to the JavaScript way, Jest against Rust's tests, package.json against Cargo.toml, Express against Axum.[12] Rust Programming in 2026 ends in three projects, a CLI tool, a small web service and an unsafe/FFI bridge to another language.[14] Two short books by Gábor Szabó take one crate each: Clap - Command Line Argument Parser for Rust on command-line arguments, from a no-library baseline through positional and named arguments, defaults, help and version text, validation, subcommands and mutually exclusive options,[22] and Liquid Templating in Rust on the Liquid template engine, from hello world through flow control, loops over vectors, HashMaps and structs, includes and layouts, to writing filters and tags of one's own.[23] Rust Blockchain: A Full-Stack Implementation Guide is the largest single system in the pool: 33 chapters that take a blockchain from the Bitcoin whitepaper to a deployable application, with Schnorr signatures, a UTXO transaction model, proof-of-work consensus, peer networking over Tokio, SQLCipher storage, an Axum REST API, two desktop wallets in Iced and Tauri 2 and deployment to Kubernetes, every chapter ending in code that compiles and runs.[19]

Desktop and WebAssembly

Building Desktop Apps & Developer Tools with Tauri 2.0, Rust, and TypeScript uses Rust as the core of desktop applications whose front end is TypeScript in the operating system's own webview, and covers Tauri 2.0's two-process model and capability-based access control, type-safe IPC, Language Server Protocol clients and VS Code extension bridges, local AI through Ollama, and heavy work offloaded to Tokio and Rayon.[24] Building Serverless Applications With WebAssembly & Spin is not a Rust book by its own account, and sends newcomers to the official Rust book first, but every example in it is Rust. Its sampled first chapter makes the case for WebAssembly components as the unit of serverless compute: a binary format that starts in under a millisecond with no operating system to boot, runs the same bytes on amd64 and arm64, is validated before it executes, and sees nothing outside its own linear memory unless the host grants a capability through WASI. It warns against repeating the claim that Wasm is a thousand times faster than containers, which measures instantiation rather than throughput. The book then grows one task-management application through a REST API, persistence, a scheduled worker and webhooks, and deploys it unchanged to Akamai's edge and to Kubernetes, against Spin 4.1, Rust 1.98 and WASI Preview 3.[9]

Neural networks, memory for AI and knowledge graphs

Candle builds neural networks from scratch with the Candle crates, and chooses Rust because, its author argues, Rust is explicit where a Python tensor is magical: every dimension is accounted for, every allocation visible, and the compiler reports a shape error before the code runs. The sample's fifth chapter is the whole pattern in one file, an Iris classifier with a two-layer model, CSV loading and normalisation, shuffled batches, a training loop with AdamW and cross-entropy and a confusion matrix at the end, in the five-step structure the book says every network follows.[5] Rust Advanced Memory Patterns for AI applies the memory model to machine-learning workloads, computation graphs under the borrow checker, shared model state behind Arc, Rc and RefCell, zero-copy slices of token sequences, arena allocators for tensors and repr(C) layout for CUDA and C libraries; it is a first volume with no sample or contents to check it against.[21] Rusty Graphs - AI Ready Graphs for Rust Developers argues that a local AI agent needs a single static binary, predictable memory and an embedded database, which Rust gives and Python makes hard, and builds a knowledge graph for one, a research assistant called Ares, through RDF, RDFS and OWL reasoning, SHACL validation, SPARQL and property graphs, with the oxigraph, reasonable and rudof crates in one Cargo workspace.[20]

Debugging Rust programs

Rust's safety does not make debugging disappear. A Rust binary still crashes, freezes and leaks, and its frames appear in a native debugger with the standard library's module paths intact. Accelerated Rust Windows Memory Dump Analysis is a WinDbg course on memory dumps from Rust processes on Windows. Its sampled exercise loads a debug-build dump, shows a stack trace of bare offsets, adds the symbol path and watches the same trace resolve into Rust, inlined frames inside the standard library's stdio, a read_line call, and the program's own crate and module functions with their source lines, then inspects a vector of thread handles and lists every thread.[8] Memory Thinking for Rust is the same author's preparation for that work, teaching the layout the debugger output shows,[7] and his Linux debugging course, whose modelling programs are written in C, C++ and Rust, is in further reading.

Sources

Every source is a Leanpub book. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.

  1. 1.
    Rust Concepts, little world Free sample: the introduction, the framing chapter on how Rust maps features to traits, and the first chapters on primitive types, variables and shadowing, expressions, if and the three loops. 2026. Free sample: PDF
  2. 2.
    Rust Patterns, little world: for Experienced Programmers Free sample: the part and chapter map and the opening of the ownership chapter, patterns one to five: Cow, Cell and RefCell, Mutex and RwLock, Drop guards and memory layout. 2026. Free sample: PDF
  3. 3.
    Rust Deep Dives, little world: how the compiler works Free sample: the introduction and chapter one, a function traced from lexing through HIR, THIR, MIR and LLVM IR to assembly, then incremental compilation, codegen units and build profiles. 2026. Free sample: PDF
  4. 4.
    Processor Architecture with Rust, little world: From Silicon to Speed Free sample: the full chapter outline and chapter three on the ALU, operation latencies, flags, two's complement and overflow. 2026. Free sample: PDF
  5. 5.
    Candle, little world: Neural Networks with Rust Free sample: chapter one on why to build networks from scratch in Rust, and chapter five, an Iris classifier from hyperparameters to confusion matrix. 2026. Free sample: PDF
  6. 6.
    Welcome to Rust, Murad Bayoun: A Journey into the World of Programming Free sample: the back matter only, a Rust cheat sheet, common compiler errors with fixes, a resource list and the start of the glossary. 2025. Free sample: PDF
  7. 7.
    Memory Thinking for Rust, Dmitry Vostokov: Slides with Descriptions and Source Code Illustrations, Second Edition Free sample: the front matter and the full table of contents of the second edition; no body pages. 2025. Free sample: PDF
  8. 8.
    Accelerated Rust Windows Memory Dump Analysis, Dmitry Vostokov Free sample: the contents and Exercise RW2, a debug-build dump's stack trace before and after symbols, with threads and locals inspected. 2024. Free sample: PDF
  9. 9.
    Building Serverless Applications With WebAssembly & Spin, Thorsten Hans Free sample: the forewords, the introduction, and the opening of chapter one on where containers fall short and what WebAssembly and WASI provide. 2026. Free sample: PDF · EPUB
  10. 10.
    Fearless Rust, Freek van Keulen: Don't Panic! No sample: from the description and its chapter outline. 2026.
  11. 11.
    Rust for Java Developers, Jitin Kayyala No sample: from the description and table of contents. 2026.
  12. 12.
    Rust for Javascript Developers, Dwayne Charrington: A Practical Guide to Systems Programming for the Web Developer No sample: from the description and table of contents. 2026.
  13. 13.
    Rust Programming, Gábor Szabó: An introduction to the Rust programming language No sample: from the one-line description and a table of contents of several hundred sections. 2025.
  14. 14.
    Rust Programming in 2026, SouthStone Publications No sample: from the description alone; the table of contents is empty. 2026.
  15. 15.
    Rust: The Complete Guide 2026 EDITION - MODERN SYSTEMS PROGRAMMING, SouthStone Publications No sample: from the description alone; the table of contents is empty. 2026.
  16. 16.
    The Accelerated Guide to Smart Pointers in Rust, Tim McNamara No sample: from the description; the table of contents is empty. 2023.
  17. 17.
    The Rust Iterator Cookbook, Eugenio Perrotta Neto: 78 recipes for writing expressive, efficient, and idiomatic iterator pipelines in Rust. No sample: from the description and a table of contents that names all 78 recipes. 2026.
  18. 18.
    Rust Projects - Write a Redis Clone, Leonardo Giordani: Explore asynchronous programming with the actor model using Rust and Tokio No sample: from the description; the table of contents is empty. 2026.
  19. 19.
    Rust Blockchain: A Full-Stack Implementation Guide, Bill Kunyiha: From whitepaper to running blockchain No sample: from the description and table of contents. 2026.
  20. 20.
    Rusty Graphs - AI Ready Graphs for Rust Developers, Volodymyr Pavlyshyn No sample: from the description and table of contents. 2026.
  21. 21.
    Rust Advanced Memory Patterns for AI, Edgar Milvus: Mastering Lifetimes, Smart Pointers, and custom allocators for managing large models and datasets No sample: from the description alone; no table of contents. 2026.
  22. 22.
    Clap - Command Line Argument Parser for Rust, Gábor Szabó: Accepting parameters on the command line. No sample: from the table of contents alone; the description is empty and the index records no publication date.
  23. 23.
    Liquid Templating in Rust, Gábor Szabó No sample: from the table of contents alone; the description is empty. 2025.
  24. 24.
    Building Desktop Apps & Developer Tools with Tauri 2.0, Rust, and TypeScript, Edgar Milvus No sample: from the description alone; the table of contents is empty. 2026.

Further reading

Other books in the library on the same ground, not cited above.

  • A Language a Day, Andrew Shitov: A brief introduction to 21 programming languages: C++, Clojure, Crystal, D, Dart, Elixir, Factor, Go, Hack, Hy, Io, Julia, Kotlin, Lua, Mercury, Nim, OCaml, Raku, Rust, Scala, and TypeScript Twenty-one languages in one book, Rust among them, each given the same four small programs; the free sample shows the C++ and Factor chapters. 2024. Free sample: PDF
  • Accelerated Linux Debugging 4D, Dmitry Vostokov: Training Course Transcript with WinDbg, GDB, LLDB, rr, KDB, KGDB Practice Exercises A Linux debugging course with WinDbg, GDB and LLDB whose modelling programs are written in C, C++ and Rust; the sampled exercise is in C. 2024. Free sample: PDF

This is an article created from the free samples of 9 Leanpub books and the descriptions and tables of contents of 15 more. We're building these articles to provide you, the Leanpub reader, with a good jumping-off point to discover more Leanpub books that are interesting and relevant to you. We never use material which is paid-only when building these articles: we only use material which is already free on Leanpub. However, Leanpub authors can opt out from inclusion in articles from their book settings page.

Updated November 2026.

In the Leanpub store: 81 books · 1 courses in the Rust category

All topics