Rust in Action
Tim McNamara
  • MEAP began July 2017
  • Publication in Early 2019 (estimated)
  • ISBN 9781617294556
  • 400 pages (estimated)
  • printed in black & white

Rust in Action introduces the Rust programming language by exploring numerous systems programming concepts and techniques.You'll be learning Rust by delving into how computers work under the hood. You'll find yourself playing with persistent storage, memory, networking and even tinkering with CPU instructions. The book takes you through using Rust to extend other applications and teaches you tricks to write blindingly fast code. You'll also discover parallel and concurrent programming. Filled to the brim with real-life use-cases and scenarios, you'll go beyond the Rust syntax and see what Rust has to offer in real-world use cases.

"The easiest way to learn Rust I've ever seen!"

~ William E. Wheeler

"Densely packed but very approachable, anyone with previous programming experience will find this book an excellent introduction to Rust."

~ Morgan Nelson

Table of Contents detailed table of contents

1. Introducing Rust

1.1. What is Rust?

1.1.1. Safety

1.1.2. Ergonomics

1.1.3. Control

1.2. Rust’s Big Features

1.2.1. Performance

1.2.2. Concurrency

1.2.3. Memory Efficiency

1.3. Downsides of Rust

1.3.1. Compile Times

1.3.2. Strictness

1.3.3. Size of the Language

1.3.4. Hype

1.3.5. Single Implementation

1.4. Where Rust Fits

1.4.1. Data Processing

1.4.2. Extending an Application

1.4.3. Operating in Resource-constrained Environments

1.4.4. Applications

1.4.5. Systems Programming

1.5. Rust’s hidden feature: its community

1.6. A Taste of the Language

1.6.1. Cheating Your Way To "Hello, world!"

1.6.2. Your First Rust Program

1.7. Summary

Part 1: Just Enough Rust

2. Language Foundations

2.1. A Glance at Rust’s Syntax

2.1.1. A whole program with main()

2.2. Starting out With Numbers

2.3. Type-aware control flow with match

2.4. Getting Stuff Done With Functions

2.5. Advanced Function Definitions

2.5.1. Explicit Lifetime Annotations

2.5.2. Generic Functions

2.6. Creating grep-lite v1

2.7. Making Lists of Things with Arrays, Slices and Vectors

2.7.1. Arrays

2.7.2. Slices

2.7.3. Vectors

2.8. Including Third Party Code

2.8.1. Adding Support for Regular Expressions

2.8.2. Generating Crates' Documentation Locally

2.8.3. Managing Rust toolchains with rustup

2.9. Supporting Command Line Arguments

2.10. Reading From Files

2.11. Reading from STDIN

2.12. Summary

3. Compound Data Types

3.1. Using plain functions to experiment with an API

3.2. Modeling Files With struct

3.3. Adding Methods to a struct with impl

3.3.1. Simplifying object creation by implementing a new() method

3.4. Returning errors

3.4.1. Modifying a known global variable

3.4.2. Making use of the Result return type

3.5. Defining and making use of enum

3.5.1. Using an enum to manage internal state

3.6. Defining Common Behavior with Traits

3.6.1. Creating a Read trait

3.6.2. Implementing Display for your own types

3.7. Exposing your types to the world

3.7.1. Protecting private data

3.8. Creating In-line Documentation

3.8.1. Using rustdoc to Render Docs For a Single Source File

3.8.2. Using cargo to Render Docs for a Crate and its Dependencies

3.9. Summary

4. Lifetimes, Ownership and Borrowing

4.1. “Implementing” a Mock CubeSat Ground Station

4.1.1. Encountering our first lifetime issue

4.1.2. Special behavior of primitive types

4.2. Guide to the figures in this chapter

4.3. What is an Owner? Does it Have any Responsibilities?

4.4. How Ownership Moves

4.5. Resolving Ownership Issues

4.5.1. Use references where full ownership is not required

4.5.2. Use Fewer Long-Lived Values

4.5.3. Duplicate the value

4.5.4. Wrap Data Within Specialty Types

4.6. Summary

Part 2: Programming from the Ground Up (Almost)

5. Data in Depth

5.1. Bit Patterns and Types

5.2. Life of an integer

5.2.1. Understanding Endianness

5.3. Decimal Numbers

5.3.1. About Floating Point

5.3.2. Looking inside an f32

5.3.3. Representing decimal numbers in a single byte with a fixed-point number format

5.4. Generating f32 values between 0 and 1 from random bytes

5.5. Implementing a CPU in Software to Establish that Functions are also Data

5.5.1. CPU 1: “the Adder”

5.5.2. First working emulator

5.5.3. CPU 2: “the Multi-Adder”

5.5.4. CPU 3: Adding functions

5.5.5. CPU 4: Adding the rest

5.6. Summary

6. Memory

7. Storage

8. Network

9. Time

10. Interruptions

Part 3: Concurrent and Parallel Programming

11. Creating a Distributed Graph

12. Sharing Resources with Locks

13. Sharing Resources with Atomic Operations

Part 4: Extending Applications Up and Out

14. C Extensions in Rust

15. Beyond the Server

About the Technology

Rust is a new systems programming language that gives you the low-level power of C with the elegance and ease of languages like Ruby and Python. Rust is thread safe, enabling "fearless concurrency". Threads are guaranteed not to overwrite each others' data, but it doesn't impose a garbage collector on you, keeping runtime performance predictable. It incorporates features from functional programming such as higher-order functions that allow for compact, readable programs. Rust is perfect for developers who want to fearlessly explore systems programming with a more ergonomic, less intimidating alternative to C or C++.

What's inside

  • Portability with Rust
  • Concurrent and parallel programming
  • Sharing resources with locks or atomic operations
  • Avoiding programming with global state
  • Message passing inside your applications
  • Memory management and garbage collection

About the reader

Readers need intermediate programming skills and familiarity with general computer science concepts, the command line, and networking.

About the author

Tim McNamara is an experienced programmer with a deep interest in natural language processing, text mining, and wider forms of machine learning and artificial intelligence. He is very active in open source communities including the New Zealand Open Source Society.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $44.99 pBook + eBook + liveBook
MEAP eBook $35.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks